Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

Co-existing with cordova-plugin-firebase-analytics: iOS doesn't receive any push notifications #2112

Open
JaneDawson opened this issue Dec 20, 2017 · 23 comments

Comments

@JaneDawson
Copy link

Expected Behaviour

Use the two plugins (phonegap-plugin-push and cordova-plugin-firebase-analytics) in parallel && be able to receive Push Notifications on iOS.

Actual Behaviour

Hi @macdonst,
when I use both phonegap-plugin-push and cordova-plugin-firebase-analytics in my app, I'm not able to receive any Push Notifications on iOS. Android works fine.
I was looking for the mistake for three days now (see: #2110) and was wondering why it wasn't working anymore.

I'm using Ionic 3. In my app.components.ts file I was using cordova-plugin-firebase-analytics to enable and disable the tracking with Firebase Analytics and phonegap-plugin-push to manage Push Notifications. In this scenario, on iOS the push registration works just fine, but no notification is ever received (see: #2110).

Now I commented out everything in app.components.ts that belongs to cordova-plugin-firebase-analytics. I did not uninstall the plugin, just comment out everything in this single file, where my Push Notification logic is. Now iOS is receiving the push notifications as expected.

Hence, it must be about the plugin. I did read the documentation part about the co-existence with Firebase Analytic plugins (Link: https://github.com/phonegap/phonegap-plugin-push/blob/master/docs/INSTALLATION.md#co-existing-with-plugins-that-use-firebase). However, this seems to be outdated, since it is about the sender ID which changed since 2.0.0 of phonegap-plugin-push, right? Additionally, I don't get any error logs like Invalid google_app_id. Firebase Analytics disabled.

I'm quite happy, that I now at least know, where to look at. That's one step forward. However, I don't know how to proceed and what to try next. I'm really desperate for your ideas on what we can try! I hope we can manage to make the two plugins work together, smoothly.

THANK YOU for your help!

Steps to Reproduce

see above

Platform and Version (eg. Android 5.0 or iOS 9.2.1)

iPad, iOS 11.2.1

Cordova CLI version and cordova platform version

cordova --version       7.1.0
cordova platform version iOS           4.5.0

Plugin version

cordova plugin version | grep phonegap-plugin-push   2.1.2

Sample Push Data Payload

The same payload worked with the old version of this plugin. For testing purposes I commented out most parts, but it still doesn't work

payload = {
                "notification":{
                    "title": "push_title",
                    "body": dataInput.message
                    // "sound": "default",
                    // "badge": badgeNo
                // },
                // "data":{
                //     "msgId": dataInput.msgId,
                //     "transactionId": dataInput.transactionId,
                }
            }

Initializing PushNotifications:

var push = PushNotification.init({
        android: {
          icon: "tauschladen_push_icon",
          iconColor: "#FF6A00",
          clearBadge: true,
          clearNotifications: true
        },
        ios: {
          alert: true,
          sound: true,
          fcmSandbox: true,
          badge: true,
          clearBadge: true
        }
      });

Logs taken while reproducing problem

FCM Registration and Firebase Analytics initialization both seem to work just fine (as you'll see in the following logs), however push.on("notification", data => { ... }) is never called, when using both plugins at the same time.

2017-12-19 16:36:26.011015+0100 Project_Name[274:7125] [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://goo.gl/ctyzm8.
2017-12-19 16:36:26.011 Project_Name[274] <Error> [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://goo.gl/ctyzm8.
2017-12-19 16:36:26.013224+0100 Project_Name[274:7134] [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40003000 started
2017-12-19 16:36:26.013 Project_Name[274] <Notice> [Firebase/Analytics][I-ACS023007] Firebase Analytics v.40003000 started
2017-12-19 16:36:26.013287+0100 Project_Name[274:7134] [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2017-12-19 16:36:26.013 Project_Name[274] <Notice> [Firebase/Analytics][I-ACS023008] To enable debug logging set the following application argument: -FIRAnalyticsDebugEnabled (see http://goo.gl/RfcP7r)
2017-12-19 16:36:26.025747+0100 Project_Name[274:7125] [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2017-12-19 16:36:26.025 Project_Name[274] <Notice> [Firebase/Messaging][I-FCM001000] FIRMessaging Remote Notifications proxy enabled, will swizzle remote notification receiver handlers. Add "FirebaseAppDelegateProxyEnabled" to your Info.plist and set it to NO
2017-12-19 16:36:26.028787+0100 Project_Name[274:7068] [CDVTimer][firebaseanalytics] 18.269956ms
2017-12-19 16:36:26.030566+0100 Project_Name[274:7068] [CDVTimer][cordovagooglemaps] 1.740038ms
2017-12-19 16:36:26.030641+0100 Project_Name[274:7068] [CDVTimer][googleplus] 0.042021ms
2017-12-19 16:36:26.056214+0100 Project_Name[274:7068] [CDVTimer][splashscreen] 25.552034ms
2017-12-19 16:36:26.061682+0100 Project_Name[274:7068] [CDVTimer][statusbar] 5.416036ms
2017-12-19 16:36:26.062397+0100 Project_Name[274:7068] [CDVTimer][keyboard] 0.642002ms
2017-12-19 16:36:26.062436+0100 Project_Name[274:7068] [CDVTimer][TotalPluginStartup] 53.493977ms
2017-12-19 16:36:26.072773+0100 Project_Name[274:7068] createNotificationChecker
2017-12-19 16:36:26.072795+0100 Project_Name[274:7068] not coldstart
2017-12-19 16:36:26.096260+0100 Project_Name[274:7068] active
2017-12-19 16:36:26.096366+0100 Project_Name[274:7068] PushPlugin skip clear badge
2017-12-19 16:36:26.135681+0100 Project_Name[274:7125] [MC] System group container for systemgroup.com.apple.configurationprofiles path is /private/var/containers/Shared/SystemGroup/systemgroup.com.apple.configurationprofiles
2017-12-19 16:36:26.136185+0100 Project_Name[274:7125] [MC] Reading from public effective user settings.
2017-12-19 16:36:26.156497+0100 Project_Name[274:7134] TIC Read Status [1:0x0]: 1:57
2017-12-19 16:36:26.156520+0100 Project_Name[274:7134] TIC Read Status [1:0x0]: 1:57
2017-12-19 16:36:26.661331+0100 Project_Name[274:7068] Ionic Native: deviceready event fired after 299 ms
2017-12-19 16:36:27.078327+0100 Project_Name[274:7068] THREAD WARNING: ['SpinnerDialog'] took '61.725830' ms. Plugin should use a background thread.
2017-12-19 16:36:27.080420+0100 Project_Name[274:7168] Push Plugin register called
2017-12-19 16:36:27.080445+0100 Project_Name[274:7168] PushPlugin.register: setting badge to true
=================================================================
Main Thread Checker: UI API called on a background thread: -[UIApplication setApplicationIconBadgeNumber:]
PID: 274, TID: 7168, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
Backtrace:
4   Project_Name                         0x000000010472dcfc __19-[PushPlugin init:]_block_invoke + 1328
5   libdispatch.dylib                   0x0000000105cd52cc _dispatch_call_block_and_release + 24
6   libdispatch.dylib                   0x0000000105cd528c _dispatch_client_callout + 16
7   libdispatch.dylib                   0x0000000105ce13dc _dispatch_queue_override_invoke + 984
8   libdispatch.dylib                   0x0000000105ce69d0 _dispatch_root_queue_drain + 624
9   libdispatch.dylib                   0x0000000105ce66f4 _dispatch_worker_thread3 + 136
10  libsystem_pthread.dylib             0x000000018659b06c _pthread_wqthread + 1268
11  libsystem_pthread.dylib             0x000000018659ab6c start_wqthread + 4
2017-12-19 16:36:27.090608+0100 Project_Name[274:7168] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication setApplicationIconBadgeNumber:]
PID: 274, TID: 7168, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
Backtrace:
4   Project_Name                         0x000000010472dcfc __19-[PushPlugin init:]_block_invoke + 1328
5   libdispatch.dylib                   0x0000000105cd52cc _dispatch_call_block_and_release + 24
6   libdispatch.dylib                   0x0000000105cd528c _dispatch_client_callout + 16
7   libdispatch.dylib                   0x0000000105ce13dc _dispatch_queue_override_invoke + 984
8   libdispatch.dylib                   0x0000000105ce69d0 _dispatch_root_queue_drain + 624
9   libdispatch.dylib                   0x0000000105ce66f4 _dispatch_worker_thread3 + 136
10  libsystem_pthread.dylib             0x000000018659b06c _pthread_wqthread + 1268
11  libsystem_pthread.dylib             0x000000018659ab6c start_wqthread + 4
2017-12-19 16:36:27.289569+0100 Project_Name[274:7168] PushPlugin.register: clear badge is set to 1
2017-12-19 16:36:27.289622+0100 Project_Name[274:7168] PushPlugin.register: better button setup
2017-12-19 16:36:27.289999+0100 Project_Name[274:7168] FCM Sender ID 1052978XXXXXX
2017-12-19 16:36:27.290044+0100 Project_Name[274:7168] Using FCM Notification
2017-12-19 16:36:27.290079+0100 Project_Name[274:7168] Using FCM Sandbox
2017-12-19 16:36:27.298785+0100 Project_Name[274:7068] PushNotification disabled
2017-12-19 16:36:27.323169+0100 Project_Name[274:7068] FCM Registration Token: XXXXXXXXBAQ:APA91bF3bmH1BOKMjtIy2H2KeOeeznHfANImhsNG2VYWuByxo3FN462Zocdi0jZweZDsOWayE1dgmFgHQw7ZdHSetXnce_1HmsAUJ8luJ_CHLQC3GBYNo2XNRM_sYH00Xrz6XXXXXXXX
2017-12-19 16:36:27.532658+0100 Project_Name[274:7127] TIC Read Status [2:0x0]: 1:57
2017-12-19 16:36:27.532790+0100 Project_Name[274:7127] TIC Read Status [2:0x0]: 1:57
2017-12-19 16:36:28.197964+0100 Project_Name[274:7068] Push Plugin register success: <XXXXXXXX 1b5ce4b4 3247c288 e834bdf5 8f7fff77 cb0d9f7e 3578a685 XXXXXXXX>
2017-12-19 16:36:29.684660+0100 Project_Name[274:7068] active
2017-12-19 16:36:29.684781+0100 Project_Name[274:7068] PushPlugin clearing badge
2017-12-19 16:36:29.717902+0100 Project_Name[274:7068] Push Plugin register success: <XXXXXXXX 1b5ce4b4 3247c288 e834bdf5 8f7fff77 cb0d9f7e 3578a685 XXXXXXXX>
@JaneDawson
Copy link
Author

Seems like removing and readding cordova-plugin-firebase-analytics is doing the trick... I'll reopen, if this was not the case.

@JaneDawson
Copy link
Author

Unfortunately, I was too quick in closing this issue. Now it's not working again :-(
Registration works fine, but notifications are not received on iOS...

@macdonst and everybody else: Do you have an idea what this is about?

@macdonst
Copy link
Member

@JaneDawson thanks for the detailed issues, it will really help when I get a chance to sit down and take a look at it. I'm assuming that the cordova-plugin-firebase-analytics plugin also registers something with FCM that directs all messages to it. Can you confirm the git repo for the plugin? Is it:

https://github.com/chemerisuk/cordova-plugin-firebase-analytics

@JaneDawson
Copy link
Author

Hi @macdonst, yes, exactly, that's it.
Thank you for looking into this! I'm really looking forward to hearing your opinion on this.

@macdonst
Copy link
Member

@JaneDawson it may not be super quick as we are rolling into the holiday shutdown and my family has already descended upon my house like a pack of ravenous wolves.

@JaneDawson
Copy link
Author

@macdonst: That sounds like a lovely Christmas Party! :D
I was actually planning on releasing the app before Christmas. Then, in the final tests this problem with pushs and analytics showed up and here I am now. Struggling to find a solution to be able to somehow keep the schedule. If you, however, find time before holiday shutdown to take a look at it, I highly appreciate it. But of course, I totally understand that you are busy with many other things, as well and that family comes first!

@JaneDawson
Copy link
Author

@macdonst: I hope you had a good start in 2018! ;-)
Did you already have the chance to look into this?
Thank you!

@JaneDawson
Copy link
Author

@macdonst: Don't want to annoy you. However, in case it may help to find the source of the problem, one observation I made:
When I initiate the two plugins (cordova-plugin-firebase-analytics) and yours, the phonegap-plugin-push, on different pages, analytics AND push notifications seem to work in most cases (unfortunately, still not in all cases).

In my case (Ionic3 app), push notifications didn't work at all, when I inititated both push and analytics in app.components.ts.
Then I tried to initiate firebase analytics in app.components.ts and push in home.ts. This leads me to working pushs and analytics in approx. 80%-90 % of the cases... After a reinstallation of the app it may even work with some of the other 10%-20%.

Obviously, this is much better, but still not good enough. I really hope, you'll find the time to look into this. I really appreciate the work you are doing here. Thank you and best regards.

@alessio-gaggii
Copy link

I have the same error logs in Xcode, but I'm not using any Firebase plugin (I use the APNS). So in my case this is not a conflict with another plugin, I guess. The App is not receiving notifications in background or foreground but Registration is successful. I'm using phonegap-plugin-push v2.1.2 (installed through npm), cordova (Cordova CLI) : 8.0.0, Cordova Platforms : ios 4.5.0 .
The notifications were and are working fine with the version 1.8.2 of the plugin.

Xcode (9.2) logs (iOS11) - Workspace build

2018-01-20 16:07:06.677158+0100 AppName[5631:2110747] Push Plugin register called
2018-01-20 16:07:06.677204+0100 AppName[5631:2110747] PushPlugin.register: setting badge to true
Main Thread Checker: UI API called on a background thread: -[UIApplication setApplicationIconBadgeNumber:]
PID: 5631, TID: 2110747, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
Backtrace:
4 AppName 0x0000000100983de4 __19-[PushPlugin init:]_block_invoke + 1328
5 libdispatch.dylib 0x0000000100ded2cc _dispatch_call_block_and_release + 24
6 libdispatch.dylib 0x0000000100ded28c _dispatch_client_callout + 16
7 libdispatch.dylib 0x0000000100df93dc _dispatch_queue_override_invoke + 984
8 libdispatch.dylib 0x0000000100dfe9d0 _dispatch_root_queue_drain + 624
9 libdispatch.dylib 0x0000000100dfe6f4 _dispatch_worker_thread3 + 136
10 libsystem_pthread.dylib 0x000000018347306c _pthread_wqthread + 1268
11 libsystem_pthread.dylib 0x0000000183472b6c start_wqthread + 4
2018-01-20 16:07:06.678022+0100 AppName[5631:2110747] [reports] Main Thread Checker: UI API called on a background thread: -[UIApplication setApplicationIconBadgeNumber:]
PID: 5631, TID: 2110747, Thread name: (none), Queue name: com.apple.root.default-qos, QoS: 21
Backtrace:
4 AppName 0x0000000100983de4 __19-[PushPlugin init:]_block_invoke + 1328
5 libdispatch.dylib 0x0000000100ded2cc _dispatch_call_block_and_release + 24
6 libdispatch.dylib 0x0000000100ded28c _dispatch_client_callout + 16
7 libdispatch.dylib 0x0000000100df93dc _dispatch_queue_override_invoke + 984
8 libdispatch.dylib 0x0000000100dfe9d0 _dispatch_root_queue_drain + 624
9 libdispatch.dylib 0x0000000100dfe6f4 _dispatch_worker_thread3 + 136
10 libsystem_pthread.dylib 0x000000018347306c _pthread_wqthread + 1268
11 libsystem_pthread.dylib 0x0000000183472b6c start_wqthread + 4
2018-01-20 16:07:06.735207+0100 AppName[5631:2110747] PushPlugin.register: clear badge is set to 1
2018-01-20 16:07:06.735305+0100 AppName[5631:2110747] PushPlugin.register: better button setup
2018-01-20 16:07:06.735475+0100 AppName[5631:2110747] Using APNS Notification
2018-01-20 16:07:06.744216+0100 AppName[5631:2110629] Push Plugin register success: <xxxxxxxx 8b52427a xxxxxxxx e09d884d xxxxxxxx 6c5e2342 xxxxxxxx c1b2ad83>

I have read other similar issues related to this Warning, like #1988 but the problem is not solved (unlike it's said for the plugin version 2.1.0).
Latest version of Cocoapods is installed, but the build from the file .xcodeproj always fails. Not sure if using the workspace is the right way. Thank you @macdonst

@Yuripetusko
Copy link

I think the reason is that firebase analytics plugin uses GoogleService-Info.plist and as soon as this push plugin sees this file it assumes that you want to use FCM instead of APNS ?

@jaigm
Copy link

jaigm commented Mar 2, 2018

@Yuripetusko we think the same

@jaigm
Copy link

jaigm commented Mar 2, 2018

@Yuripetusko i find a way to use apns having GoogleService-Info.plist. You have to change the value of the key IS_GCM_ENABLED to false

@Yuripetusko
Copy link

@javitoxhz Thank you! I actually found it out also, but forgot to post it here :) 👍

@hariomtechnologies4u
Copy link

@Yuripetusko @javitoxhz setting IS_GCM_ENABLED to false is not solving my issue. Is there anything else which also need to be done in order to use both firebase analytics & APNS through push plugin?

@jaigm
Copy link

jaigm commented Apr 23, 2018

@hariomtechnologies4u Check if the token that you get has no a colon mark (:), if the token has it, it's mean is a firebase token, and maybe you have to re-build the app after update the settings in the .plist file. If the token has no colon mark, maybe the problem is in your notification server. BTW, I solved the problem just changing the value IS_GCM_ENABLED.

@hariomtechnologies4u
Copy link

@javitoxhz IS_GCM_ENABLED never worked for me even after re-build. So, I had changed file path of Googleservices-info.plist in pushplugin.m file so that push plugin never get googleservices-info.plist file of firebase and both APNS & firebase work simultaneously.

@ardabeyazoglu
Copy link

ardabeyazoglu commented Feb 15, 2019

I had recently this issue. The only solution worked for me is this:

  1. Remove both plugins, remove platform ios
  2. cordova plugin add phonegap-plugin-push@2.1.3 --save
  3. Clone the cordova-plugin-firebase-analytics repo, modify plugin.xml and set firebase/core podspec to 4.0.0
  4. cordova plugin add {forked-repo-url}.git
  5. pod install (in ios folder)

Now both works normally.

@crawft
Copy link

crawft commented Mar 4, 2019

@ardabeyazoglu Trying to follow this but there isn't a podspec for firebase-messaging in the analytics plugin.xml?

@ardabeyazoglu
Copy link

@crawft it must be core not messaging, sorry.

@xinfengmich
Copy link

xinfengmich commented May 8, 2019

cordova-plugin-firebase-analytics@0.12.0 seems working with phonegap-plugin-push@2.2.3.
Will phonegap-plugin-push have a release to update FirebaseMessaging framework dependence ? framework src="FirebaseMessaging" type="podspec" spec="~> 2.0.0" seems little out of date.

@viv-design
Copy link

Are you planning on actually fixing this issue in the near future????

@smartsanja2013
Copy link

If anyone manage to resolve this issue, please help to resolve below issues.

Versions

ionic version 4.6.0
"cordova": "9.0.0",
"cordova-android": "8.0.0",
"cordova-clipboard": "^1.3.0",
"cordova-ios": "5.1.1",

"cordova-plugin-firebase-analytics": "1.1.1",
"phonegap-plugin-push" : 2.3.0

On Android

`Failed to capture fingerprint of input files for task ':app:preDebugBuild' property` 'compileManifests' during up-to-date check.
    > In project 'app' a resolved Google Play services library dependency depends on another at an exact version (e.g. "[16.0.
      0]", but isn't being resolved to that version. Behavior exhibited by the library will be unknown.

      Dependency failing: com.google.firebase:firebase-messaging:17.0.0 -> com.google.firebase:firebase-iid@[16.0.0], but fire
      base-iid version was 17.1.2.



        The following dependencies are project dependencies that are direct or have transitive dependencies that lead to the art
          ifact with the issue.
          -- Project 'app' depends onto com.google.firebase:firebase-iid@17.1.2
          -- Project 'app' depends onto com.google.firebase:firebase-analytics@16.5.0
          -- Project 'app' depends onto com.google.firebase:firebase-messaging@17.0.+
          -- Project 'app' depends onto com.google.android.gms:play-services-measurement-api@16.5.0
          -- Project 'app' depends onto com.google.firebase:firebase-core@16.0.+
          -- Project 'app' depends onto com.google.firebase:firebase-core@16.0.9
          -- Project 'app' depends onto com.google.firebase:firebase-messaging@17.0.0

on IOS

Analyzing dependencies
[!] CocoaPods could not find compatible versions for pod "FirebaseAnalytics":
  In snapshot (Podfile.lock):
    FirebaseAnalytics (= 5.8.1)

  In Podfile:
    Firebase/Core (~> 5.6) was resolved to 5.20.2, which depends on
      FirebaseAnalytics (= 5.8.1)

    FirebaseMessaging (~> 2.0.0) was resolved to 2.0.8, which depends on
      FirebaseAnalytics (~> 4.0) 

@AndrWeisR
Copy link

I had recently this issue. The only solution worked for me is this:

  1. Remove both plugins, remove platform ios
  2. cordova plugin add phonegap-plugin-push@2.1.3 --save
  3. Clone the cordova-plugin-firebase-analytics repo, modify plugin.xml and set firebase/core podspec to 4.0.0
  4. cordova plugin add {forked-repo-url}.git
  5. pod install (in ios folder)

Now both works normally.

I am having these same plugin incompatibility problems. The steps above allowed me to add both the analytics and push plugins on iOS, but I still get a build error in Xcode: "Module 'FirebaseInstanceID' not found". I have already done the manual pod install, i.e.

cd platforms/ios
pod install

which runs successfully, but still the "Module 'FirebaseInstanceID' not found" error persists. I have done a pod repo update, and a build clean in Xcode.

Where do I go from here?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests