1

I am not able to receive push notifications on iOS devices using phonegap-plugin-push. The device is registered successfully with FCM and I have received the registrationId as well without any issues. But when I try pushing the notifications from FCM/Postman the device sometimes logs the notifications received and sometimes it doesn't.

Here are my configurations:

  • Ionic : 3.19.0
  • Cordova : 8.1.2
  • cordova-ios : 5.1.1
  • phonegap-pluginpush : 2.3.0

Below are the steps followed to configure FCM:

  1. Created a Project in FCM console
  2. Added an iOS Application with the app bundle id/package name
  3. Uploaded the APNS authentication keys (P8 file) generated in developer.apple.com

I have the provisioning profiles and certificates created properly to make the push notifications work. I have placed the GoogleService-Info.plist file in the root of the project directory and I have enabled the Background Modes in Xcode and the app also has the Push Notifications capability added.

Below is the code:

  • Installed the phonegap-plugin-push with sender ID

    cordova plugin add phonegap-plugin-push --senderID="XXXXXXXX"

  • I have created a push service and have called the push methods within that on platform.ready event
   public deviceID: string;
   private pushObject: PushObject;
   private options: PushOptions = {
     android: {
       senderID: '',
     },
     ios: {
       alert: true,
       badge: true,
       sound: false
     },
   };

   constructor(private push: Push) {
        this.platform.ready()
        .then(source => {
            if (source === 'cordova') {
                this.init();
            }
        });
    }

    init(): void {
        this.pushObject = this.push.init(this.options);
        this.registerDevice();
        this.receiveNotifications();
        this.handlePushErrors();
    }

    registerDevice(): void {
        this.pushObject.on('registration')
            .subscribe(data => {
                this.deviceID = data.registrationId;
            });
    }

    receiveNotifications(): void {
        this.pushObject.on('notification').subscribe(notification => {
            console.log('onNotification-->', JSON.stringify(notification));
        });
    }

    private handlePushErrors(): void {
        this.pushObject.on('error').subscribe(e => console.error(`Push object error: ${e}`));
    }

The logs in XCode is as follows:

 4.13.0 - [Firebase/Core][I-COR000003] The default Firebase app has not yet been configured. Add `[FIRApp configure];` (`FirebaseApp.configure()` in Swift) to your application initialization. Read more: https://firebase.google.com/docs/ios/setup#initialize_firebase_in_your_app.
2020-05-25 13:23:17.072513+0530 Your Bank[895:312952] 4.13.0 - [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40200000 started
2020-05-25 13:23:17.072867+0530 Your Bank[895:312952] 4.13.0 - [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see https://help.apple.com/xcode/mac/8.0/#/dev3ec8a1cb4)
FCM Registration Token: dDUDsgulex8:APA91bESy4iycqrnn0ANJ8piMo4I_Vzzt3Bfci2bxxxxxxxxxxxxBqa2ohv6tke4OICFzjmyEt9kbZ-3YFttVQUfHlmrQDy36Ffz_xxxxxxxxxxxxxxxxxxxxxxxxx
Push Plugin register success: {length = 32, bytes = 0xcffbfefa 6f27d9b5 9e4f3dad 9b78447a ... fee6ba5a 1fc2e06b }
PushPlugin skip clear badge

Along with the above output I have also seen one warning as below, and once I added the FirebaseAppDelegateProxyEnabled to info list the warning is gone but still I am not able to receive notifications on the iOS device

2020-05-26 11:21:47.194933+0530 Your Bank[1077:493657] 4.13.0 - [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. If you'd prefer to manually integrate Firebase Messaging, add "FirebaseAppDelegateProxyEnabled" to your Info.plist, and set it to NO. Follow the instructions at:
https://firebase.google.com/docs/cloud-messaging/ios/client#method_swizzling_in_firebase_messaging
to ensure proper integration.

However, the Android works seamlessly with the above code and configurations and I always receive notifications on Android devices but with iOS devices, the behavior is not consistent and the issue is intermittent (sometimes I receive it & sometimes I don't) but the server logs are clear and there are no errors thrown on FCM side.

0 Answers0