iOS Objective-C registering device for Push - Issue within the AppDelegate

Hi Backendless,
Hopefully you have some great plans for the weekend and your not ALL working!
So, I am doing really well in the app with Backendless, thank you, but I now have a problem.
I have this method current in the AppDelegate:

  • (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

[backendless initApp:APP_ID secret:SECRET_KEY version:VERSION_NUM];
[backendless.userService setStayLoggedIn:YES];

@try {
[backendless initAppFault];
}
@catch (Fault *fault) {
NSLog(@“didFinishLaunchingWithOptions: %@”, fault);
}
return [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];

}
But I need to add this for Push registration… Cant have the two ‘return’ values in the method.
NSDictionary *remoteDict = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
if (remoteDict)
[self application:application didReceiveRemoteNotification:remoteDict];
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];
return YES;
So, question is how do I implement registration when using FBSDK too…
Cheers
Steve

Hi Steve,

I assume you use the latest version of SDK (if not, make sure to grab it from our github repo). To initiate push notification registration sequence, you do this first:

[backendless.messaging registerForRemoteNotifications];

You can call it right from didFinishLaunchingWithOptions. Also make sure to declare the following callback in your app delegate:

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken {
  // register device with Backendless here
}

As the line 2 suggests, you will need to make another call there, which will be one of the “registerDevice” methods which take the “deviceToken” argument. For example this one:

Btw, the messaging doc will be updated with this information as early as next week.

Hope this helps.

Mark

Hi Mark,

This worked like a charm and my devices are registering. Thanks

Cheers

Steve