IM,令牌pushnotification iOS8上的VS使用獲得令牌的推送通知下面的代碼行ios7的PhoneGap
我加入了下一行的支持iOS8上,但是當加入這些線路的IPA工作在iOS8上但不在ios7上,ios7上的應用程序在打開後立即關閉。
- (BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
#ifdef __IPHONE_8_0
//Right, that is the point
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIRemoteNotificationTypeBadge
|UIRemoteNotificationTypeSound
|UIRemoteNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
#else
//register to receive notifications
UIRemoteNotificationType myTypes = UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound;
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:myTypes];
#endif
#ifdef __IPHONE_8_0
- (void)application:(UIApplication *)application didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings
{
//register to receive notifications
[application registerForRemoteNotifications];
}
- (void)application:(UIApplication *)application handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo completionHandler:(void(^)())completionHandler
{
//handle the actions
if ([identifier isEqualToString:@"declineAction"]){
}
else if ([identifier isEqualToString:@"answerAction"]){
}
}
#endif
在iOS 7上運行應用程序時看到的異常是什麼? – ebi 2014-10-28 17:34:51
registerUserNotificationSettings:]:無法識別的選擇器發送到實例0x16d71c60 2014-10-31 12:56:00.899 ClickMobileCDV [1875:60b] ***終止應用程序,由於未捕獲異常'NSInvalidArgumentException',原因:' - [UIApplication registerUserNotificationSettings:] :無法識別的選擇器發送到實例0x16d71c60' ***第一次拋出調用堆棧: – 2014-10-29 08:59:35