1
我在擁有工作推送通知的appstore中有一個應用程序。我創建了一個新的應用程序,並試圖使用相同的應用程序ID來獲取通知。我確定我的包標識符與舊應用程序相匹配,推送通知已啓用,並且didRegisterForRemoteNotificationsWithDeviceToken正在獲取令牌。我的服務器正在向蘋果的APNS服務發送應用程序,但是從不會調用ReceiveRemoteNotification。我正在使用部署構建來測試它。推送通知適用於舊應用程序,但不適用於新應用程序
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)
}
應用程序處於死亡狀態並且您看到橫幅時,應用程序是否會收到推送? – Shubhank
我已經嘗試過在後臺和前臺應用程序,它不發送。我的應用必須運行才能觸發服務器發送推送請求 – user1079052
爲什麼需要運行? – Shubhank