简体   繁体   中英

Trying to get push notifications using Parse.com not working on device

So i am trying out Parse.com Push notification service.

I have done all the steps etc and when i try to run on the simulator the app runs but when i try to run it on my Iphone Device (Iphone 5s) the application crashes with the following error code:

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'

This is the code

- (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;

}

EDIT

My iphone is not fully updated. Version is 7.1

Try this

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

       }

This didn't work for me, yet it got me going in right direction and after days of searching I found this other stack link: RegisterUserNotificationSettings is not working in ios 6.1 .
Added it in and everything is good.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM