我使用Parse.com發送推送通知我的iOS應用。 但是當我執行下面的代碼來創建PFInstallation
對象時,設備令牌字段爲空。didRegisterForRemoteNotificationsWithDeviceToken不執行 - 推送通知
- (void)application:(UIApplication *)application
didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)newDeviceToken {
// Store the deviceToken in the current installation and save it to Parse.
NSLog(@"didRegisterForRemoteNotificationsWithDeviceToken");
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:newDeviceToken];
[currentInstallation saveInBackground];
}
didFinishLaunchingWithOptions
方法
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
// Override point for customization after application launch.
[Parse setApplicationId:@"xhjhkk869698lhlljk554hl55khlkhl4ff99065" clientKey:@"spg1t6jad1ShK2lh5456khh6j7j4nmn1YD6J6rl8vt3"];
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
[FBProfilePictureView class];
// Register for push notifications
[application registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
[[UIApplication sharedApplication] setStatusBarHidden:YES withAnimation:UIStatusBarAnimationNone];
return YES;
}
我注意到,從不執行didRegisterForRemoteNotificationsWithDeviceToken
。我過檢查了我的證書和配置配置文件,我使用的方法指定here(見下製作一個PEM文件)對它們進行測試。證書和連接正常工作。我還檢查了我的wifi是否阻止推送通知,沒有問題。
所以任何人都可以請建議我在做什麼錯在這裏?
是警報空間PoPing當你註冊遠程通知? – soryngod
沒有任何反應 –
您是在設備上還是在模擬器上測試應用程序? – soryngod