andrehtissot / cordova-plugin-fcm-with-dependecy-updated

Google FCM Push Notifications Cordova Plugin
MIT License
208 stars 277 forks source link

Not able to receive notification on iOS 12+ #267

Open imajayverma opened 3 years ago

imajayverma commented 3 years ago

The plugin is working fine in android , but on iOS it's not working. I'm using plugin version 7.4.0, also tried 7.5.0 on both ionic 3 and ionic 5. Other latest version of plugin even 7.8.0 is giving build error. Please help

Ionic: Ionic CLI : 5.4.6 Ionic Framework : ionic-angular 3.9.2 @ionic/app-scripts : 3.2.4

Cordova: Cordova CLI : 10.0.0 Cordova Platforms : ios 6.1.1 NodeJS : v10.17.0 npm : 6.11.3 OS : macOS Catalina Xcode : Xcode 12.0.1 Build version 12A7300

@andrehtissot

Ibni-Amin commented 3 years ago

I have also the same issue

mstockbridge2000 commented 3 years ago

Were either of you able to figure out the cause? We have been looking at this for a month can can't figure it out. Android works great but IOS does not receive notificaiton.

freescout-helpdesk commented 3 years ago

On iOS the following code should be called in the very beginning:

        // Needed for iOS
        if (typeof(window.cordova.platformId) == "undefined" || window.cordova.platformId != 'android') {
            // Asks only once
            FCM.requestPushPermission()
                .then(function (didIt) {
                    if (didIt) {
                        // Do nothing
                    }
                })
                .catch(function (error) {
                    alert('Error occurred: '+error)
                });
        }
DrDaxter commented 3 years ago

I'm having the same error, could someone help me? I'm using ionic 4

metadevj commented 3 years ago

For Ionic 5, please make sure that import to the correct file:

import { FCM } from "cordova-plugin-fcm-with-dependecy-updated/ionic";

carpiodanielj commented 3 years ago

On iOS the following code should be called in the very beginning:

        // Needed for iOS
        if (typeof(window.cordova.platformId) == "undefined" || window.cordova.platformId != 'android') {
            // Asks only once
            FCM.requestPushPermission()
                .then(function (didIt) {
                    if (didIt) {
                        // Do nothing
                    }
                })
                .catch(function (error) {
                    alert('Error occurred: '+error)
                });
        }

Didn't work for me, any other suggestion?

DrDaxter commented 3 years ago

I was able to figure out this issue, to get notifications on iOS you must create an Apple Push Services certificate and Apple Push Notifications service (APNs) after that you have to go to your firebase project, go to project settings, cloud messaging, inside the iOS app configuration upload the APNs Auth Key and Development APNs certificate, make sure to add your team id you can find it in your apple developer account, inside the membership. Good luck