尝试使用Parse.com获取推送通知而不在设备上工作

时间:2015-01-08 22:39:30

标签: ios iphone parse-platform push-notification

所以我正在尝试Parse.com推送通知服务。

我已完成所有步骤等,当我尝试在模拟器上运行应用程序运行但当我尝试在我的Iphone设备(Iphone 5s)上运行时,应用程序崩溃并出现以下错误代码:

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

2 个答案:

答案 0 :(得分:4)

试试这个

    // 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];

       }

答案 1 :(得分:0)

这对我来说没有用,但它让我朝着正确的方向前进,经过几天的搜索,我找到了另一个堆栈链接: RegisterUserNotificationSettings is not working in ios 6.1
添加它,一切都很好。