我想在我的iOS應用程序中使用解析通知,我按照parse.com網站上的步驟指導了一步步,但它仍然無效,這裏是我的應用程序委託.M解析通知不適用於iOS
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[Parse enableLocalDatastore];
// Initialize Parse.
[Parse setApplicationId:@"XXXXXXXXXXXX"
clientKey:@"XXXXXXXXXXX"];
// [Optional] Track statistics around application opens.
[PFAnalytics trackAppOpenedWithLaunchOptions:launchOptions];
NSLog(@"START");
// Register for Push Notitications
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
{
// iOS 8 Notifications
[application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
[application registerForRemoteNotifications];
}
else
{
// iOS < 8 Notifications
[application registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
}
[self grabStoryboard];
[FBLoginView class];
[FBProfilePictureView class];
return YES;
}
- (void)application:(UIApplication *)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
// Store the deviceToken in the current installation and save it to Parse.
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
[currentInstallation setDeviceTokenFromData:deviceToken];
[currentInstallation saveInBackground];
}
- (void)application:(UIApplication *)application didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
if (error.code == 3010) {
NSLog(@"Push notifications are not supported in the iOS Simulator.");
} else {
// show some alert or otherwise handle the failure to register.
NSLog(@"application:didFailToRegisterForRemoteNotificationsWithError: %@", error);
}
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[PFPush handlePush:userInfo];
}
在parse.com我看到,我已經1個註冊的設備,但是當我點擊「發送推送」發出的推是0
是的,我用同樣的包標識符上傳它我的應用 –
但仍然無法正常工作 –