FrancescoMussi
FrancescoMussi

Reputation: 21630

Ionic Push Notification: Not receiving in IOS

THE SITUATION:

I use Ionic Push Notifications in my app.

With android everything works fine. But with IOS I don't receive any notification.

The code should be fine. The registration of the token it works properly also inside IOS devices. I can see the token in the database.

Also the cURL request code should be fine since it is working for android.

I will paste below all the info that may be useful:

THE CODE:

Initialization:

$ionicCloudProvider.init({

    "core": 
    {
        "app_id": "MY_APP_ID"
    },
    "push": 
    {
        "sender_id": "MY_SENDER_ID",
        "pluginConfig": {
            "ios": {
                "badge": true,
                "sound": true
            }
        }
    }
});

io-config.json:

{"app_id":"MY_APP_ID","api_key":"MY_API_KEY","dev_push":false,"gcm_key":"MY_GCM_KEY"}

THE CERTIFICATES:

In ionic.io I have setup the certificate - production mode - and activate all the credentials: ionic.io certificate

Inside the Apple Developer Console, the Push Notifications service is properly enabled (for production)

enter image description here

THE TESTS:

The app is already published in the App store.

Anyway i made tests both locally through XCODE (with the devices connected to it) and directly downloading the app from the app store.

I never received any notifications.

Making a test using POSTMAN this is the outcome:

{
  "data": {
    "status": "open",
    "uuid": "b55a9024-d0d9-480e-a813-02053bcf2f2a",
    "created": "2016-09-19T14:05:01.097422+00:00",
    "state": "enqueued",
    "app_id": "MY_APP_ID",
    "config": {
      "tokens": [
        "THE_RECEIVER_TOKEN"
      ],
      "notification": {
        "message": "Push test"
      },
      "profile": "MY_IONIC_IO_PROFILE"
    }
  },
  "meta": {
    "status": 201,
    "request_id": "dbb57cba-3817-42ee-baaf-7175b5f6c755",
    "version": "2.0.0-beta.0"
  }
}

THE QUESTION:

Why I am not receiving any notification on IOS?

Am i missing something?

Thank you!

Upvotes: 1

Views: 1482

Answers (2)

user6698531
user6698531

Reputation:

  1. Make sure you have latest version of Ionic i,e v2 and above.

  2. In path src/app/app.components.ts

  3. After platform.ready().then(() => { add the below code

    var push = Push.init({
     android: {
     senderID: "XXXXXXXXX"
     },
     ios: {
      alert: "true",
      badge: true,
      sound: 'false'
     },
     windows: {}
    });
    
    push.on('registration', (data) => {
     console.log(data.registrationId);
     alert(data.registrationId.toString());
    });
    
    push.on('notification', (data) => {
     console.log(data);
    });
    
  4. After build (ionic build ios) open the ionic project in Xcode and in general and team section choose an account which has paid apple developer account.

  5. Then in capabilities enable push notification.

  6. If all the other constraints like certificate and .p12 files are done as per apple guild lines then push will surely work.

  7. For more info visit this link : http://ionicframework.com/docs/v2/native/push/

Upvotes: 0

lubilis
lubilis

Reputation: 4170

  • Make sure notifications are enabled in your iOS settings app
  • Try using content_available = true in push payload
  • Try using priority = "high" in push payload
  • Make sure you're not sending using development certificates on a production app version or viceversa
  • Make sure your token is valid and refreshed

Docs about priority and content_available attributes

From docs:

On iOS, set content_available when the app server needs to send a Send-to-Sync message. An inactive client app will execute your logic in the background, while an app in the foreground will pass the message to didReceiveRemoteNotification:.

Upvotes: 3

Related Questions