7

In Onesignal api, I have added isIos => true,ios_badgeType => Increase,ios_badgeCount => 1,content_available => true in the field array. But the badge count always remains as 1, it's not increasing with multiple messages.

This is my payload details : $fields = array( 'app_id' => "xxxxxx", 'included_segments' => array('All'), 'data' => array( "notification_type" => "update" ), 'contents' => $content, 'subtitle' => $subtitle, 'headings' => $heading, 'isIos' => true, 'ios_badgeType' => "Increase", 'ios_badgeCount' => 1, 'content_available' => true );

P.Banerjee
  • 189
  • 2
  • 14
  • Add code what you are doing – vivekDas Aug 01 '18 at 07:31
  • remove ios_badgeCount this field. May be your problem will solve – Chirag Shah Aug 01 '18 at 07:50
  • Your payload details? What is complete payload keys and format? – Mathi Arasan Aug 01 '18 at 07:57
  • This is my payload details :$fields = array( 'app_id' => "xxxxxx", 'included_segments' => array('All'), 'data' => array( "notification_type" => "update" ), 'contents' => $content, 'subtitle' => $subtitle, 'headings' => $heading, 'isIos' => true, 'ios_badgeType' => "Increase", 'ios_badgeCount' => 1, 'content_available' => true ); – P.Banerjee Aug 01 '18 at 08:58
  • 2
    +1 I am experiencing the same issue. One thing I did notice was if you set ios_badgeCount to 2. The app's badge icon will always be 2, so it is as if we are using the SetTo ios_badgeType. I reached out to OneSignal's support team, so I will post an update here if/when I hear back from them. – M. Carlson Aug 01 '18 at 15:39
  • 2
    @chiragshah you will get a 400 response from OneSignal if you don't include the ios_badgeCount in the body of the request – M. Carlson Aug 01 '18 at 15:40
  • I am having the same problem... – the_martux Aug 05 '18 at 13:25
  • @M.Carlson any updates? – P.Banerjee Aug 17 '18 at 06:50

2 Answers2

3

You must add Notification Extension in order to get badge auto update. Please follow the link to setup.

Also, need to create app group and assign both bundle id to that particular group. Please see the section -

In order for your application to be able to let push notifications increment/decrement the badge count, you need to set up an App Group for your application.

See here

P.Banerjee
  • 189
  • 2
  • 14
1

Please follow https://documentation.onesignal.com/docs/ios-sdk-app-groups-setup in detail.

The name of your app group should be

group.{your_bundle_id}.onesignal

So for example, if your application's bundle identifier is com.test.app, your app group name should be group.com.test.app.onesignal.

Assign the group to both target.

  1. Open your Info.plist file and add a new OneSignal_app_groups_key as a String type.
  2. Enter the group name you checked in the last step as it's value.
  3. Make sure to do the same for the Info.plist under the OneSignalNotificationServiceExtension folder.