0
votes

I've implemented push notifications with AppCenter on an ASP.Net Core Web API. Server is sending HTTP requests to AppCenter that is in charge of pushing notifications to each platforms Android & iOS.

Mobile apps are developed with Xamarin Forms. I've followed Microsoft documentation here

Xamarin Android application is receiving every push notifications like a charm.

The problem is for Xamarin iOS application. Devices are not receiving any push notification.

Here is iOS settings I've made:

  • Enabled push notifications in Entitlements for production (not development)
  • Created an APN key for push notifications in my Apple developer account for production
  • Provided iOS APN key to AppCenter settings (with APP ID, Prefix...)
  • Enabled remote notifications in background mode in info.plist
  • Disabled swizzling by adding AppCenterAppDelegateForwarderEnabled key to info.plist
  • Overrided DidReceiveRemoteNotification in AppDelegate and implements methods RegisteredForRemoteNotifications , FailedToRegisterForRemoteNotifications

Then, I've successfully published the app to TestFligth in production mode.

When launching the app, I'm getting appcenter device InstallId by calling method AppCenter.GetInstallIdAsync().

Finally, when push notification is sent, nothing happens. And I don't have any logs to search the problem.

Is there something I missed to make it work ?

1
Did you tried sending the Push from App Center console instead of your backend with the Installation ID you get? - Nirmal Subedi
Yes I tried to all iOS registered devices but nothing is received anyway - Ricavir
Are you testing with a real device? Check the steps here. - Jack Hua
Yes, I'm testing with a real device over TestFligth. The link you mention is giving steps when using directly APNS but in my case, I'm using AppCenter which makes all necessary steps to register for push notifications...Moreover, we I launched the iOS app, I have an alert popup which asks to allow my app to show notifications. Meaning AppCenter is doing the job... - Ricavir
I did not use AppCenter before. There are lots of possibilities that may cause this problem. I suggest you to check if you are using a production certification instead of a development certification. - Jack Hua

1 Answers

0
votes

AppCenter provides a different AppSecret for each platform. You should do :

        if (Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.iOS)
        {
            //Start AppCenter Push notification with iOS app secret
            AppCenter.Start("xxxxxxxxxxxxxxxxxxxxxxx", typeof(Push));
        }
        else if (Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.UWP)
        {
            //Start AppCenter Push notification with UWP app secret
            AppCenter.Start("xxxxxxxxxxxxxxxxxxxxxxx", typeof(Push));
        }
        else if(Xamarin.Forms.Device.RuntimePlatform == Xamarin.Forms.Device.Android)
        {
            //Start AppCenter Push notification with Android app secret
            AppCenter.Start("xxxxxxxxxxxxxxxxxxxxxxx", typeof(Push));
        }