Search code examples
iosxcodeparse-platform

Error when adding parse push notifications


As you can see in the image below I get the following error. The project is an existing project so I followed the tutorial on parse. I seem to get this error and the parse website recognises 0 devices. I am new to parse and ios so any help would be much appreciated.

https://i.sstatic.net/SdNVr.jpg


Solution

  • You are placing functions into other functions in a very wrong way. It should look like this:

    - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    {
        [Parse setApplicationId:@"bla" clientKey:@"bla"];
    
        [application registerForRemoteNotificationTypes:
                     UIRemoteNotificationTypeBadge |
                     UIRemoteNotificationTypeAlert |
                     UIRemoteNotificationTypeSound];
        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 didReceiveRemoteNotification:(NSDictionary *)userInfo
    {
        [PFPush handlePush:userInfo];
    }
    

    You definitely need to read some code fundamentals.