私は奇妙な問題があります。iOS APNが届きません
コードが通知をregistrateする以下の通りです:
func application(application: UIApplication, didFinishLaunchingWithOptions launchOptions: [NSObject: AnyObject]?) -> Bool {
// PUSH NOTIFICATION
let notificationTypes: UIUserNotificationType = [UIUserNotificationType.Alert, UIUserNotificationType.Badge, UIUserNotificationType.Sound]
let pushNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)
application.registerUserNotificationSettings(pushNotificationSettings)
application.registerForRemoteNotifications()
および通知を処理するために:
func application(application: UIApplication, didReceiveRemoteNotification userInfo: [NSObject : AnyObject], fetchCompletionHandler completionHandler: (UIBackgroundFetchResult) -> Void) {
let notification = UILocalNotification()
notification.soundName = UILocalNotificationDefaultSoundName
notification.alertBody = "TEST"
application.presentLocalNotificationNow(notification)
私は(デバイスではなく、シミュレータと)Xcodeで、この単純なコードをテストする場合、問題ない。しかし、xcodeを使わずに(私の電話で)テストすると、ローカルの通知は表示されません。音声はありません。アラートはありません。バッジはありません。
アプリがバックグラウンドで実行されているときに問題が発生します。
送信されるAPNはサイレント通知です。
これを修正するにはどうすればよいですか?
EDIT
I 5にサイレントAPNの優先度を減少させることによってそれを解決しました。
アプリがバックグラウンドで実行されているときに問題が発生します。 – Thomi
** xcodeなしでテストするとどういう意味ですか? – Dershowitz123
私はデバッグをしないでください。私はちょうどそれをテストするために私の携帯電話でアプリを実行します。 – Thomi