1
からの通知を受信していない、私はAPNのための次のプロセスを持っていますデバイスは、アップルのプッシュ通知にトークンに登録は私のアプリでサーバー
- didFinishLaunchingWithOptionsでデバイスを登録します。
- didRegisterForRemoteNotificationsWithDeviceTokenでトークンを受信;
- 通知サーバーに送信します。
- 私のサーバーが通知を送信します。
- 問題:デバイスが受信しません(didReceiveRemoteNotification)。
すでにサーバーと証明書のアプリケーションIDが確認されています。
誰かが間違っていることを指摘できますか?
AppDelegate.m
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Checking if app is running iOS 8
if ([application respondsToSelector:@selector(registerForRemoteNotifications)]) {
// Register device for iOS8
UIUserNotificationSettings *notificationSettings = [UIUserNotificationSettings
settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge |
UIUserNotificationTypeSound categories:nil];
[application registerUserNotificationSettings:notificationSettings];
[application registerForRemoteNotifications];
} else {
// Register device for iOS7
[application registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound | UIRemoteNotificationTypeBadge];
}
//...
return YES;
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(@"Registration successful, bundle identifier: %@, device token: %@",
[NSBundle.mainBundle bundleIdentifier], deviceToken);
// Receive the token and send it to my Server
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
NSLog(@"Error in registration. Error: %@", err);
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
// Handle notification
}
サンドボックスAPNSサーバーを使用していますか?デバッグモードでは、Sandbox APNSと証明書 – Lefteris
[このリンク](https://github.com/noodlewerk/NWPusher)を使用する必要があります。 – Mahesh
開発環境の証明書を使用してファイルごとに作成し、サンドボックスモードで使用する必要がある開発については、プッシュ通知を構成するために必要な環境ごとに、アプリケーションの環境を確認する必要があります。サンドボックスなしで証明書を発行します。 – Rajat