iOS Push Notification issue ONLY on Production

Hey.

I have some Business Logic code setup to send a push notification to a specific iOS device every time a “MessageObject” is created. This has been working for the past few months, but it stopped working all of a sudden.
I’ve tried running the code through the debugger (Debug mode) and it works fine there. However, whenever I deploy the code to the Production environment, I keep getting this error everytime:

FAULT = ‘0’ [com.backendless.Messaging.publish(Ljava/lang/Object;Lcom/backendless/messaging/PublishOptions;Lcom/backendless/messaging/DeliveryOptions;)Lcom/backendless/messaging/MessageStatus;] <com.backendless.Messaging.publish(Ljava/lang/Object;Lcom/bac

Here’s the code that sends the push notification to an iOS device:

private void sendNotification(BackendlessUser user, String type) {
    String receivingDeviceID = (String)user.getProperty("deviceId");

    DeliveryOptions deliveryOptions = new DeliveryOptions();
    deliveryOptions.setPushPolicy(PushPolicyEnum.ONLY);
    deliveryOptions.addPushSinglecast(receivingDeviceID);

    PublishOptions publishOptions = new PublishOptions();
    publishOptions.putHeader("ios-content-available", "1");
    publishOptions.putHeader("ios-sound", "default");
    publishOptions.putHeader("ios-badge", "1");

    if (type.equalsIgnoreCase("Text")) {

        String countryCode = (String) user.getProperty("countryCode");

        if (countryCode.equalsIgnoreCase("FO")) {
            publishOptions.putHeader("ios-alert", "Tú hevur fingið svar frá onkrum");
            Backendless.Messaging.publish("Tú hevur fingið svar frá onkrum", publishOptions, deliveryOptions);
        } else {
            publishOptions.putHeader("ios-alert", "You received a reply from someone");
            Backendless.Messaging.publish("You received a reply from someone", publishOptions, deliveryOptions);
        }
    }
}

I don’t understand why this works fine in Debug but not in Production. Can anyone answer this?

I tried re-downloading the source code from the dashboard and then redeploying. This seems to have solved the issue.

I am having the same issue. It works in debug but not in production. This seems to be a recent problem as it used to work like a week ago.

Is there an exception from the server-side code? Try putting all of the code in the method into a try/catch(Throwable t) block and then using the logging API to capture the exception (if there is any). Make sure to set the log buffer to 1 so the log message are sent to the server right away:
https://backendless.com/documentation/business-logic/java/bl_logging.htm

Ok, I added logging, where do I see if anything was logged?

In Backendless Console, go to Files and then “logging”. Details are in the doc:
https://backendless.com/documentation/manage/mgmt_logging.htm

Yeah I don’t see any new files, I guess there are no errors… I mean if there were any errors they would have showed up in the debug console wouldn’t they?

You could add another log statement at the very last line of the try{} block…

What’s “debug console”?

By debug console I mean CodeRunner, when I use code runner it doesn’t show any errors locally and sends the push notification just fine. However when I am in production mode the message does not show up in the Messaging panel in the console.

Ok, apparently I was not logging correctly. I got this error in the log file:

http://pastebin.com/2Hutfz48

In this paste bin, you can see the method i wrote, and at the end the error that is found in the log.

I am getting a run time error: java.lang.NoSuchMethodError
java.lang.NoSuchMethodError: com.backendless.Messaging.publish(Ljava/lang/Object;Lcom/backendless/messaging/PublishOptions;Lcom/backendless/messaging/DeliveryOptions;)Lcom/backendless/messaging/MessageStatus;

Hi, Minitour!

We had changes in SDK so you need to use the latest Android SDK and CodeRunner. The best way is to regenerate Business Logic Code, add your custom code and deploy it again.

I think that’s what made it work for me.

I had to download the business logic code again from the Backendless console, copy-paste my own code back in, and then deploy.