ios push notification sound and badger

Hello,
I am sending a push notification in server code on event afterCreate. The push works, except that there is no sound and the badge does not increment.
Here is my code in JAVA:

@Async
@Override
public void afterCreate( RunnerContext context, Notification notification, ExecutionResult<Notification> result ) throws Exception
{
 DeliveryOptions deliveryOptions = new DeliveryOptions();
 deliveryOptions.setPushPolicy(PushPolicyEnum.ONLY);
 deliveryOptions.setPushBroadcast(PushBroadcastMask.IOS);
 PublishOptions publishOptions = new PublishOptions();
 publishOptions.putHeader("ios-alert", "Hello iOS");
 publishOptions.putHeader("ios-sound", "default");
 publishOptions.putHeader("ios-badge", "increment");
 
 MessageStatus status = Backendless.Messaging.publish("testchannel", "testing IOS push", publishOptions, deliveryOptions);
}

Hi Gabriel,

Please read the following comment regarding audio for the iso-sound notifications:
http://support.backendless.com/t/swift2-how-do-i-sent-push-to-my-users#comment-9593

As for badge value, you can use the following API to auto-increment the count and use the counter value for the badges:
https://backendless.com/documentation/utilities/ios/ut_atomic_counters_ios.htm

Regards,
Mark

Does not work. I get no sound and no badge count. Is there something wrong with my code?

I receive the push, but no badge and no sound.

The links did not help solve my problem

This is not answered. I still cannot get sound or badge.

This is certainly wrong, the value of the header must be a number. Sending “increment” does nothing.

publishOptions.putHeader(“ios-badge”, “increment”);

As for the sound, did you read the comment I linked? Have you included the sound file into the main bundle of the client app or in the Library/Sounds folder of the app’s data container?

I changed it to

publishOptions.putHeader(“ios-badge”, “1”);

It still does not work. I even tried on the console, using “ios-alert”:“some text”,“ios-badge”:“1”,“ios-sound”:“default”

I got the push, but no sound and no badge.

Also, you do not need to have an audio file in the bundle if you specify “default” it should play the default notification sound of the iphone

Does your app include .Badge and .Sound types in UIUserNotificationSettings?

OK, I found the problem.

I had the following code in my iOS app to register the device for notifications. The documentation needs to be updated, because it says: “The method above registers device with APNS for all available notification types (alert, badge and sound)”.

Apparently, that is not true, because I changed it from

backendless.sharedInstance().messaging.registerForRemoteNotifications()

To:

let settings = UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil)
application.registerUserNotificationSettings(settings)
application.registerForRemoteNotifications()

And now it works!

Thanks for your help

I am glad you got it working. I suspect you’re not using the latest build of our library, since in there the code registers for all notification types:

Regards,
Mark