尝试使用 Parse.com 无法在设备上运行来获取推送通知
Trying to get push notifications using Parse.com not working on device
所以我正在尝试 Parse.com 推送通知服务。
我已完成所有步骤等,当我尝试在模拟器上运行时,应用程序运行,但当我尝试在我的 Iphone 设备上运行它时(Iphone 5 秒),应用程序崩溃错误代码如下:
015-01-08 17:28:45.607 PickMeUp[451:60b] -[UIApplication registerForRemoteNotifications]:
unrecognized selector sent to instance 0x1576016f0
2015-01-08 17:28:45.610 PickMeUp[451:60b] *** Terminating app
due to uncaught exception 'NSInvalidArgumentException', reason:
'-[UIApplication registerForRemoteNotifications]: unrecognized selector sent to instance 0x1576016f0'
这是代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[Parse setApplicationId:@""];
// Register for Push Notitications
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings]; // The app crashes here
[application registerForRemoteNotifications];
return YES;
}
编辑
我的iphone没有完全更新。版本为 7.1
试试这个
// Register for Push Notitications
if ([application respondsToSelector: @selector (registerUserNotificationSettings :)]) {
UIUserNotificationSettings * settings = [UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound
categories: nil ];
[[UIApplication sharedApplication] registerUserNotificationSettings: settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
//ios7
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
}
这对我不起作用,但它让我朝着正确的方向前进,经过几天的搜索,我找到了另一个堆栈 link:
RegisterUserNotificationSettings is not working in ios 6.1.
添加进去,一切正常。
所以我正在尝试 Parse.com 推送通知服务。
我已完成所有步骤等,当我尝试在模拟器上运行时,应用程序运行,但当我尝试在我的 Iphone 设备上运行它时(Iphone 5 秒),应用程序崩溃错误代码如下:
015-01-08 17:28:45.607 PickMeUp[451:60b] -[UIApplication registerForRemoteNotifications]:
unrecognized selector sent to instance 0x1576016f0
2015-01-08 17:28:45.610 PickMeUp[451:60b] *** Terminating app
due to uncaught exception 'NSInvalidArgumentException', reason:
'-[UIApplication registerForRemoteNotifications]: unrecognized selector sent to instance 0x1576016f0'
这是代码
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
// Override point for customization after application launch.
[Parse setApplicationId:@""];
// Register for Push Notitications
UIUserNotificationType userNotificationTypes = (UIUserNotificationTypeAlert |
UIUserNotificationTypeBadge |
UIUserNotificationTypeSound);
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:userNotificationTypes
categories:nil];
[application registerUserNotificationSettings:settings]; // The app crashes here
[application registerForRemoteNotifications];
return YES;
}
编辑
我的iphone没有完全更新。版本为 7.1
试试这个
// Register for Push Notitications
if ([application respondsToSelector: @selector (registerUserNotificationSettings :)]) {
UIUserNotificationSettings * settings = [UIUserNotificationSettings settingsForTypes: UIUserNotificationTypeBadge | UIUserNotificationTypeAlert | UIUserNotificationTypeSound
categories: nil ];
[[UIApplication sharedApplication] registerUserNotificationSettings: settings];
[[UIApplication sharedApplication] registerForRemoteNotifications];
} else {
//ios7
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeSound];
}
这对我不起作用,但它让我朝着正确的方向前进,经过几天的搜索,我找到了另一个堆栈 link:
RegisterUserNotificationSettings is not working in ios 6.1.
添加进去,一切正常。