Onesignal-ios-sdk: Support for iOS10 adding title thru iOS code

Created on 16 Sep 2017  ·  2Comments  ·  Source: OneSignal/OneSignal-iOS-SDK

Can you please guide us on how to send a notification with a title for iOS 10?

We tried like this

OneSignal.postNotification(["contents": ["en": message],
                                    "data": payload,
                                    "title": title,
                                    "ios_badgeCount" : 1,
                                    "ios_badgeType": "Increase",
                                    "include_player_ids": [recieverId]])

and like this

OneSignal.postNotification(["contents": ["en": message, "title": title],
                                    "data": payload,
                                    "ios_badgeCount" : 1,
                                    "ios_badgeType": "Increase",
                                    "include_player_ids": [recieverId]])

but it didn't work.

Most helpful comment

@KMSoft2013 For title you will need to add a headers field, it is same object format as contents.

OneSignal.postNotification([
   "contents": ["en": messageBody],
   "headings": ["en": messageTitle],
   "title": title,
   "data": payload,
   "ios_badgeCount" : 1,
   "ios_badgeType": "Increase",
   "include_player_ids": [recieverId]
])

All others options from the REST API are accessible as well, except for other targeting parameters.
https://documentation.onesignal.com/reference#create-notification

All 2 comments

@KMSoft2013 For title you will need to add a headers field, it is same object format as contents.

OneSignal.postNotification([
   "contents": ["en": messageBody],
   "headings": ["en": messageTitle],
   "title": title,
   "data": payload,
   "ios_badgeCount" : 1,
   "ios_badgeType": "Increase",
   "include_player_ids": [recieverId]
])

All others options from the REST API are accessible as well, except for other targeting parameters.
https://documentation.onesignal.com/reference#create-notification

Thanks, @jkasten2 Now I can send a notification with a title.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dirkoswanepoel picture dirkoswanepoel  ·  5Comments

adambolcsfoldi picture adambolcsfoldi  ·  4Comments

ldco2016 picture ldco2016  ·  3Comments

cassidyclawson picture cassidyclawson  ·  5Comments

chmiiller picture chmiiller  ·  6Comments