Support Topics Documentation Slack YouTube Blog

Push notification is not working - iOS and Android

We have two applications in IOS and Android created for QA and production purposes. The production app is the replica of the QA app. We are able to send push notification from the QA app and is working fine.But push notification is not working in production build.

Verified the certificate - it is the universal certificate for both Sandbox and Production
Verified sending notification from the console and is working fine

  • (void)saveAndSendAlert:(SystemAlert *)alert {

    // Check for internet connection.
    if (![[ASNetworkAlertClass sharedManager] isInternetActive]) {
    [[ASNetworkAlertClass sharedManager] showInternetErrorAlertWithMessage];
    return;
    }

    id dataStore = [backendless.persistenceService of:[SystemAlert class]];
    [dataStore save:alert response:^(id result) {

      [MBProgressHUD hideHUDForView:self.view animated:YES];
      DataQueryBuilder *queryBuilder = [DataQueryBuilder new];
      [backendless.persistenceService find:[BackendlessUser class] queryBuilder:queryBuilder response:^(NSArray *results) {
          [ReadiResponseUtils sendPushNotificationToUsers:results withMessage:alert.descriptionText withBadgeCount:@0 forAlert:alert]; [self.tableView reloadData];
      } error:^(Fault *fault) {
          NSLog(@"Error: %@", fault.description);
          UIAlertController *alert = [UIAlertController alertWithTitle:@"Error sending alert" message:fault.message];
          [self presentViewController:alert animated:YES completion:nil];
      }];
      
      UIAlertController *alert = [UIAlertController alertWithMessage:@"Your alert has been sent" okHandler:^(UIAlertAction *okAction) {
          dispatch_async(dispatch_get_main_queue(), ^{
              [[self navigationController] popViewControllerAnimated:YES];
          });
    
      }];
    

// UIAlertController *alert = [UIAlertController alertWithMessage:@“Your alert has been sent” okHandler:^{
// [[self navigationController] popViewControllerAnimated:YES];
// }];
[self presentViewController:alert animated:YES completion:nil];
} error:^(Fault *fault) {
NSLog(@“Error: %@”, fault.description);
[MBProgressHUD hideHUDForView:self.view animated:YES];
UIAlertController *alert = [UIAlertController alertWithTitle:@“Error sending alert” message:fault.message];
[self presentViewController:alert animated:YES completion:nil];
}];
}

The above code is the Objective C code that is used to send push notification to users in IOS.
We are able to fetch the users data from user’s table.But push notification is not received by any of the users in the production build.The same works fine in the QA app!!!

Backendless Version (3.x / 5.x, Online / Managed / Pro )

5.2.14

Client SDK (REST / Android / Objective-C / Swift / JS )

Objective-C (v4.0.20)

Application ID

E2380C63-B49A-5F86-FF77-77B2DC8DB000

Hello Kevin,

I’ve checked iOS push notifications in production mode and everything works fine - I’m not experiencing any problems with Backendless. Please make sure you’ve configured your Xcode project correctly for the production, your BundleId is correct and your certificate is set to the production mode.
For now I can advise you to try NWPusher - it is a great simple tool to check your app with push notifications.

Regards,
Olha

I tried in NWPusher and i am getting push notifications in my device.So it is not a certificate issue.Is there any other way to solve this issue?

Hi, Kevin.

Can you provide minimal example to reproduce? We’ll try to check the same code with our certificates.

Regards, Andrii.

You can attach the project’s archive here or send it to the support@backendless.com.

Regards,
Olha

Thank you,

I am cc the development team. Really appreciate it.

Kevin

I have cc the team on this as well.

Thank you

Kevin

We are using below code to send push notification to users

  • (void)sendPushNotificationToUsers:(NSArray *)users withMessage:(NSString *)message withBadgeCount:(NSNumber *)badgeCount forAlert:(id)alert {

    //DeliveryOptions *deliveryOptions = [DeliveryOptions deliveryOptionsForNotification:PUSH];
    DeliveryOptions *deliveryOptions = [DeliveryOptions new];
    [deliveryOptions publishPolicy:PUSH];
    NSMutableArray *deviceIds = [[NSMutableArray alloc] init];

    for (BackendlessUser *user in users) {

      if ([user isKindOfClass:[NSDictionary class]] || [user isKindOfClass:[NSMutableDictionary class]]) {
          BackendlessUser *userModel = [[BackendlessUser alloc] initWithProperties:(NSDictionary *)user];
          
          if ([userModel getProperty:@"userDeviceId"] != nil) {
              [deviceIds addObject:[userModel getProperty:@"userDeviceId"]];
          }
      } else {
          if ([user getProperty:@"userDeviceId"] != nil) {
              [deviceIds addObject:[user getProperty:@"userDeviceId"]];
          }
      }
    

    }

    deliveryOptions.pushSinglecast = deviceIds;

    if (deviceIds.count > 0) {
    PublishOptions *publishOptions = [PublishOptions new];
    // add @“rAlert” : alert to headers was the beginning to deep linking push notifs, removing due to crash
    NSDictionary *androidHeaders = @{@“android-content-title” : @“READIResponse”, @“android-content-text” : message, @“ios-badge” : badgeCount, @“ios-sound” : @“READIResponse-PI-Alert.wav”};
    [publishOptions assignHeaders:[androidHeaders mutableCopy]];

      @try {
          MessageStatus *result = [backendless.messagingService publish:@"default" message:message
                                                         publishOptions:publishOptions deliveryOptions:deliveryOptions];
          NSLog(@"MessageStatus = %@ <%@>", result.messageId, result.status);
      } @catch (Fault *fault) {
          NSLog(@"FAULT = %@", fault);
      }
    

    }
    }

Please note we are using Backendless v5.2.14, and iOS SDK v4.0.20

Hello Kevin,
We’ve asked for a project to check your project configuration. Would you mind sending us the working project, not just a code snippet?

If you’ve already sent it I apologize but I don’t see it in the support@backendless.com mailbox.

Regards,
Olha

Project file is send to support@backendless.com from the email account stanly.johnson@rapidvaluesolutions.com.Please do reply if you haven’t received the mail.

Hi @kevin

We’ve recieved your project and someone will definitely look into it by Monday morning.
You’ve mentioned that push notifications in Android not working as well?
Can you please provide more details on this:

  • share your code for push notification publishing in Android
  • share a complete file of your Android manifest

Anton

Hello Kevin,

I’ve checked your project and I have some remarks.

Firstly, for the future, please send a Minimal, Reproducible Example - e.g. your project requires login which isn’t related to the notifications problems.

Secondly, I’d like to ask you to check your project carefully once more. It is configured for the debug mode, not for the release one:

I’ve connected our production certificates and that’s what I’ve got with NWPusher:
1 - Production certificate, debug mode, “Should use sandbox environment” - I’m able to receive push notifications:

2 - Sandbox environment turned off - invalid token.

Project is configured for the debug mode, not the release.
If you can receive notifications via NWPusher in the production mode with Sandbox environment turned off - please send us the Minimal, Reproducible Example of the production configured project.

Regards,
Olha

Sorry ,I have send the project file in debug mode.I will change it to production mode and will send the project file again.

I am also sending you the android project file to support@backendless.com from the email account stanly.johnson@rapidvaluesolutions.com.

Hi Kevin

so, don’t you receive Push Notifications on Android devices either? or is the issue only with iOS?

Regards, Vlad

Hi Vladimir Upirov

We have the push notification issue in both iOS and Android.

Regards,
Kevin

if you don’t receive Push Notifications on Android devices, I guess the problem is not with Apple certificate, isn’t it?

I think it is not a certificate issue.We have tried to send push notification using NWPusher with the same certificate used in our project and we are getting push notification in the device.

Hello Kevin,

I’ve received the project in release mode and checked it. Everything works fine. That’s the steps I’ve done:

  1. Install pods
  2. Open .xcworkspace file
  3. Change Bundle ID and Team (because I’m not in your team and I can’t use your certificates). Also I’ve changed signing for iPhone distribution

  1. Register my iPhone in the OlhaTest channel and uploaded my production certificate for this channel

  1. Send push notification in the OlhaTest channel and received it on my phone

Maybe something is wrong with provisioning profiles but push notifications work fine with Backendless.
Our Android developer will also check push notifications and give a response here.

Regards,
Olha

Hi, @Kevin_McClain

I checked your Android project. Push notifications work fine for both debug and release version of application.
I want to notice, that I tested both debug and release builds with production Backendless application with ID: E2380C63-B49A-5F86-FF77-77B2DC8DB000.
Here are the steps I’ve done:

  1. Subscribe to OlhaTest channel.
  2. Replace debug appId&apiKey with release values to be able to receive push notifications from production Backendless app in debug build.
  3. Run debug build, send push notification and receive it.
  4. Create release apk, install on the phone, run the application, send push and also receive it.

Maybe you mix up the apps. I assume that you can send push notification from production app and expect to receive it in QA app or vice versa. So you don’t see anything.

Regards,
Maksym