Hi guys,
I am now venturing into Backendless Push integration you will undoubtably be over joyed to hear ;-). As such I have the customary newbie issue… I am working through the ‘PushNotify’ iOS example project as well as following the docs for Push.
Ok, first here is my code and then some questions below:
AppDelegate (devices and Channel register perfectly, well they all show up in the DB GUI):
@interface AppDelegate () <IBEPushReceiver>
@end
@implementation AppDelegate
-
(BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[backendless initApp:APP_ID secret:SECRET_KEY version:VERSION_NUM];
[backendless.messaging registerForRemoteNotifications];
[backendless.userService setStayLoggedIn:YES];
@try {
[backendless initAppFault]; BackendlessUser *user = backendless.userService.currentUser; NSLog(@"USER IS HERERERERERERE: %@", user); NSString *myChannel = user.objectId; NSString *info = [backendless.messagingService registerDevice:@[myChannel]]; backendless.messagingService.pushReceiver = self; NSLog(@"viewDidLoad -> registerDevice: %@", info);
}
@catch (Fault *fault) {
NSLog(@"didFinishLaunchingWithOptions: %@", fault);
}
return [[FBSDKApplicationDelegate sharedInstance] application:application didFinishLaunchingWithOptions:launchOptions];
}
-
(void)application:(UIApplication )app didRegisterForRemoteNotificationsWithDeviceToken:(NSData)deviceToken {
[backendless.messaging didRegisterForRemoteNotificationsWithDeviceToken:deviceToken];
}
-
(void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err {
[backendless.messaging didFailToRegisterForRemoteNotificationsWithError:err];
}
-
(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
[backendless.messaging didReceiveRemoteNotification:userInfo];
}
-
(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler {
[backendless.messaging didReceiveRemoteNotification:userInfo];
handler(UIBackgroundFetchResultNewData);
}
ViewController method (for now I am just trying to send a Push to myself hence sending on my own channel):
-
(IBAction)myBuyingItemNudgeButton:(id)sender {
NSString *myChannel = backendless.userService.currentUser.objectId;
NSLog(@“THIS IS THE CHANNEL: %@”,myChannel);
PublishOptions *options = [PublishOptions new];
options.headers = @{@“publisher_name”:@“Panda”, @“ios-badge”:@“1”, @“ios-sound”:@“Sound12.aif”, @“ios-content-available”:@“1”};
[backendless.messagingService publish:myChannel message:@“Hello Test” publishOptions:options deliveryOptions:[DeliveryOptions deliveryOptionsForNotification:PUSH_ONLY] response:^(MessageStatus *res) {
NSLog(@"showMessageStatus: %@", res);
}
error:^(Fault *fault) {
NSLog(@"sendMessage: fault = %@", fault);
}];
}
Questions:
-
I get this error when sending the push message: showMessageStatus: <MessageStatus> messageId: B67FE4B1-428A-BFF9-FFB7-515859A54E00, status: SCHEDULED errorMessage: (null) is there something wrong with my code?
-
I am creating a channel for each user so they can be notified individually, is this the right approach? Basically what user1 wants to notify user2 of something they will simply get User2’s objectID and send a message on their channel… In theory anyway…
-
WHY IS THE WORLD SO STRANGE… sorry that was just one of my random thoughts.
Regards
Steve