Notifications from OneSiganl for iOS 10 is not working. things i have rechecked again that i am using..

Xcode 8.1, Swift 3, Added latest provisioning cert, Under capabilities push notifications are on with entitlement,

My app delegate methods are

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

  OneSignal.initWithLaunchOptions(launchOptions, appId: ONE_SIGNAL_APPID)
    OneSignal.setLogLevel(.LL_VERBOSE, visualLevel: .LL_NONE)
   OneSignal.initWithLaunchOptions(launchOptions, appId: ONE_SIGNAL_APPID, handleNotificationReceived: {

        (Notification) in            

    }, handleNotificationAction: { (action) in

    }, settings:[kOSSettingsKeyAutoPrompt: true ,
                  kOSSettingsKeyInFocusDisplayOption:OSNotificationDisplayType.notification.rawValue]) }

And for registering the device with id.

     func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data) {

     OneSignal.sendTag("myType", value: "myBroadCast")

    OneSignal.idsAvailable { (userId, deviceToken) in

        let userId = String(format: "%@", userId!)
        DataManager.sharedInstance.deviceToken = userId;

        print("player id",userId)

I have got the playerid i.e userId apparently. So my device is registered successfully.

The thing is that the api notifications are not receiving on my device. Other than OneSignal sample push messages (which are working fine),

My API payload for notification is

    {"alert":{"notification":{"notification_type":1,"v_n":"Custom Place","u_n":"customer","c_id":907,"m_id":1207,"m_t":"1","f_a":0,"d_d":"07 Dec, 2016","t_t":"07:40 AM","is_group_chat":true},"body":"hxuf"},"badge":1,"sound":"NewMessage.mp3"}

Please help me in this regard. As this problem is only with iOS 10 devices.

1 Answers 11

up vote 0 down vote accepted

If your making a POST REST API call to your JSON format isn't correct. The JSON payload should be as follows for the OneSignal notification based on your contents from your JSON example in your question.

   "app_id": "YOUR_ONESIGNAL_APP_ID",
   "contents": {"en": "hxuf"},
   "ios_badgeType": "SetTo",
   "ios_badgeCount": 1,
   "data": {"notification_type":1,"v_n":"Custom Place","u_n":"customer","c_id":907,"m_id":1207,"m_t":"1","f_a":0,"d_d":"07 Dec, 2016","t_t":"07:40 AM","is_gr`oup_chat":true}

Note1: You must set a targeting parameter such as include_player_ids as a JOSN array to a list of OneSignal player / user ids. Or use another targeting parameter such as included_segments. See the full tarting options in the OneSignal documentation page at the bottom of this answer.

Note2: .mp3 files can't be used for notification sounds for iOS. You must convert it to a .wav or .caf format.

See OneSignal's full documentation on the create REST API call endpoint below.

Thank you very much. The payload was in wrong format. – Adeel Noor

Not the answer you're looking for? Browse other questions tagged or ask your own question.