Support Topics Documentation Slack YouTube Blog

Updated Certificate and iOS push notifications worked temporarily...then stopped working

(John Edmonds) #1

Push notification tests from backendless work fine to all devices. Recently updated the certificate and the in-app notifications for messaging worked for a short period of time within my app, but then ceased to function. Any idea why they temporarily worked and are no longer working? Thanks.

(Vyacheslav Vdovichenko) #2

Please try our sample project (see in attachment) changing with your Bundle Identifier, appID & secretKey.

It works for us, let us know how it works for you. (19.55MB)

(John Edmonds) #3

Thanks for your reply … The sample code works and so my code too. The issue is my client complains about code stop working after sometime. Which is weird because the iOS as well as Cloud code is not changed. Here is the code comparison of Sample Code and Alike code to help you understand the issue …

Sample Code to receive notification:

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { 
[backendless.messaging didReceiveRemoteNotification:userInfo];

Alike Code:
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo { 
NSLog(@"%@", userInfo); 
[self handleNotification:userInfo]; // The function passes the information to Apps to refresh different views based on notification type 
[backendless.messaging didReceiveRemoteNotification:userInfo];

Sample Code to register for notification: 
backendless.messaging.notificationTypes = UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge; 
[backendless.messaging registerDeviceWithChannels:@[@"testing"]];

Alike Code: 
[backendless.messaging registerForRemoteNotifications]; 
[backendless.messaging registerDeviceToken:deviceToken];

Sample Code: 
NSDictionary *publishHeaders = @{ @"publisher_name":@"Tester", @"ios-badge":@"1", @"ios-sound":@"default", @"ios-content-available":@"1", @"android-content-text":@"Content text", @"android-content-title":@"Title", @"android-ticker-text":@"Ticker text" };
PublishOptions *publishOptions = [PublishOptions new]; 
[publishOptions assignHeaders:publishHeaders];
DeliveryOptions *deliveryOptions = [DeliveryOptions new]; 
[deliveryOptions pushPolicy:PUSH_ONLY]; 
[deliveryOptions pushBroadcast:FOR_ANDROID|FOR_IOS];
[backendless.messagingService publish:@"testing" message:@"ONE" publishOptions:publishOptions deliveryOptions:deliveryOptions 
response:^(MessageStatus *status) { NSLog(@"Message has been sent: %@", status); } error:^(Fault *fault) { NSLog(@"Server reported an error: %@", fault); }];

Alike Code: 
PublishOptions *publishOptions = [PublishOptions new]; 
[publishOptions addHeader:@"ios-alert" value:alertText]; 
DeliveryOptions *deliveryOptions = [DeliveryOptions new]; 
NSMutableArray* list = [NSMutableArray arrayWithArray:@[toUserDeviceId]]; deliveryOptions.pushSinglecast = list; 
BackendlessUser* user = backendless.userService.currentUser;
NSString* alertText = [NSString stringWithFormat:@"%@: %@",[user getProperty:PROPERTY_FIRSTNAME],msg];
NSDictionary *data = [NSDictionary dictionaryWithObjectsAndKeys: alertText, @"alert", user.objectId, @"id", @"c", @"type", nil];
[backendless.messagingService publish:@"default" message:data publishOptions:publishOptions deliveryOptions:deliveryOptions 
response:^(MessageStatus *messageStatus) { 
NSLog(@"MessageStatus = %@ <%@>", messageStatus.messageId, messageStatus.status); } 
error:^(Fault *fault) { NSLog(@"FAULT = %@", fault); } ];

(Vyacheslav Vdovichenko) #4

John, to compare the pieces of code is not helpful. Could you provide your project (or some sample project which demonstrates the issue) here or to We could investigate it and give a solution for you.

(John Edmonds) #5

A side note: I am sending the message to a user instead of a channel. I am maintaining the mapping of user to deviceid.

(Vyacheslav Vdovichenko) #6

Internal ticket BKNDLSS-13038 is created.

(Vyacheslav Vdovichenko) #7

Hi John,

We cannot reproduce this issue with our sample project (see in attachment). We have made an ad hoc app, loaded it to our devices and checked how it publish and receive the notifications. It works fine during a long time.

The advantage of this project is that it is demonstrating a pure Backendless SDK usage. You can set your Bundle Identifier, certificate, distribution provisioning profile, appId and secretKey, and try it. How it will work for you.

Slava (20.58MB)