【发布时间】:2016-08-05 14:51:05
【问题描述】:
我在应用商店中有一个具有有效推送通知的应用程序。我创建了一个新应用程序,并尝试使用相同的应用程序 ID 使通知正常工作。我确保我的包标识符与旧应用程序匹配,启用推送通知并且 didRegisterForRemoteNotificationsWithDeviceToken 正在获取令牌。我的服务器正在将应用程序发送到 Apple 的 APNS 服务,但从未调用过 didReceiveRemoteNotification。我正在使用部署版本对此进行测试。
func application(application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: NSError) {
print("Failed to register:", error)
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject]) {
processPushMessage(userInfo)
print("recieved alert :\(userInfo)");
}
func application(application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: NSData) {
profile.reset()
getObjects()
print("didRegisterForRemoteNotificationsWithDeviceToken")
let tokenChars = UnsafePointer<CChar>(deviceToken.bytes)
var tokenString = ""
for i in 0..<deviceToken.length {
tokenString += String(format: "%02.2hhx", arguments: [tokenChars[i]])
}
print("Device Token:", tokenString)
}
【问题讨论】:
-
当应用处于终止状态并且您看到横幅时,应用是否会收到推送?
-
我已经在后台和前台尝试了该应用程序,但它没有发送。我的应用程序必须运行才能触发服务器发送推送
-
为什么需要运行?
-
它是在连接 Asterisk 呼叫时发送的,所以我需要打开它来连接呼叫。
-
我建议只是尝试使用github.com/noodlewerk/NWPusher 发送一个简单的推送,应用程序被杀死,如果收到调试为什么你没有在前台推送。否则,调试你的配置和证书,看看为什么你根本没有收到推送
标签: ios iphone swift push-notification