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

App crashes after refreshing when using FCM (v2) #1497

Closed
AndreasGassmann opened this issue Jan 3, 2017 · 7 comments
Closed

App crashes after refreshing when using FCM (v2) #1497

AndreasGassmann opened this issue Jan 3, 2017 · 7 comments
Assignees
Milestone

Comments

@AndreasGassmann
Copy link

I have an Ionic2 app and I'm using the v2 branch of this plugin to use FCM push notifications. I noticed that the app crashes when refreshing it using safari. My initial thought was to only call the .init() method after the first launch, but according to the docs the registrationId might change and it should be called on every app launch.

After reading a bit on stackoverflow, it might be related to this issue: http://stackoverflow.com/questions/37910766/app-crashing-when-using-firebase-auth-reason-default-app-has-already-been-con

Maybe it could be fixed with the following snippet:

    // Configure Firebase
    // ------------------
    if FIRApp.defaultApp() == nil {
        FIRApp.configure()            
    }

Expected Behaviour

When refreshing the app, I expect the app to work normally and the push registration to succeed (or be skipped)

Actual Behaviour

The app crashes after refreshing

Steps to Reproduce

Build and run app using FCM and v2 from XCode
Wait for the registration to go through (without any errors)
Open Safari Dev Tools
Refresh the Page
App will load but crash once it tries to register again

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

iOS 10.1

Cordova CLI version and cordova platform version

cordova --version: 6.4.0
cordova platform version ios: 4.3.1

Plugin version

cordova plugin version | grep phonegap-plugin-push: 2.0.0-rc1 "PushPlugin"

Logs taken while reproducing problem

2017-01-04 00:06:36.083123 App[xxx] PushPlugin.register: setting badge to false
2017-01-04 00:06:36.083136 App[xxx] PushPlugin.register: clear badge is set to 0
2017-01-04 00:06:36.083146 App[xxx] PushPlugin.register: better button setup
2017-01-04 00:06:36.090700 App[xxx] FCM Sender ID xxx
2017-01-04 00:06:36.090921 App[xxx] Using FCM Notification
2017-01-04 00:06:36.103581 App[xxx] *** Terminating app due to uncaught exception 'com.firebase.core', reason: 'Default app has already been configured.'
*** First throw call stack:
(0x1842221c0 0x182c5c55c 0x184222108 0x10027e430 0x10027e1f8 0x100215118 0x100ec525c 0x100ec521c 0x100eca284 0x1841cff2c 0x1841cdb18 0x1840fc048 0x185b82198 0x18a0e72fc 0x18a0e2034 0x1000e90e4 0x1830e05b8)
libc++abi.dylib: terminating with uncaught exception of type NSException```

The error happens at [FIRApp configure]; on line 333 in the following file: https://github.com/phonegap/phonegap-plugin-push/blob/v2.0.x/src/ios/PushPlugin.m 
@jcesarmobile
Copy link
Collaborator

Looks like we missed this PR after the rebase
#1396

@macdonst macdonst added this to the Release 2.0.0 milestone Jan 4, 2017
@macdonst macdonst self-assigned this Jan 4, 2017
@macdonst
Copy link
Member

macdonst commented Jan 4, 2017

@AndreasGassmann yeah, that is my screw up on a rebase. I will fix today and maybe get RC2 out.

@AndreasGassmann
Copy link
Author

Ok, thanks!

@macdonst
Copy link
Member

macdonst commented Jan 4, 2017

@AndreasGassmann I just pushed the fix to the v2.0.x branch. Give it a try and let me know if it resolves the issue for you, it should and I'll start looking at that RC2 candidate push to NPM.

@AndreasGassmann
Copy link
Author

Works like a charm. Thanks!

@macdonst
Copy link
Member

macdonst commented Jan 5, 2017

@AndreasGassmann releasing a 2.0.0-rc2 now.

macdonst added a commit that referenced this issue May 25, 2017
* Added partial Android FCM support (#975)

* Modified plugin.xml to include FCM changes

* Plugin.xml changes for FCM

* Java changes for FCM

* Increased plugin version to 2.0.0

* Increased plugin version in package.json

* Added topic subscription/unsubscription

* Removed some empty lines

* Fixed empty token on android first run (#1008)

* Removed GCM files and added FCM files

* Added .framework files as custom frameworks

* Changed code to work with FCM

* Added hook and resource file to copy GoogleService-Info.plist

* fixed registration and removed unused code

* Use CocoaPods

* Fix rebase errors

* Fix topic subscription and unsubscription on FCM

* Refactor GCMIntentService to FCMService

* Issue #689: Remove sender id from PushNotification init Android options

* Issue #689: Remove sender id from PushNotification init iOS options

* 📝 Update to using fcm-node

* 🐛 Issue #1188: Strings.xml google_app_id conflict with google-services.json

* Add empty google services plist

* Pin FCM to 9.8.0

* 🔧 Add browser platform back for FCM branch

* 🔨🔧⬆️ Use Babel to transpile ES2015 code

* 🔧 add tern to gitignore

* 🔖 Bumping plugin version to 2.0.0-rc1

* 2.0.0-rc1

* Updating CHANGELOG

* Fixing my merge error for PR #1378 Optional event emit instead of function call for action buttons

* 🐛🍎 Issue #1461: App crashes when initialising with topics (v2.0.0-rc1)

* 🐛🐧📝⬆️ #1460: Build Issue Android

* 🐛🍎🔧 Fixing a merge issue where aps-environment was accidentally removed

* 🐧📝🐛 Issue #1470: Cannot install phonegap-plugin-push on master

* 📝 Using a newer version on the examples

* 🍎🐛 Issue #1497: App crashes after refreshing when using FCM (v2)

* Bumping plugin version to 2.0.0-rc2

* 2.0.0-rc2

* Updating CHANGELOG

* Added partial Android FCM support (#975)

* Modified plugin.xml to include FCM changes

* Plugin.xml changes for FCM

* Java changes for FCM

* Increased plugin version to 2.0.0

* Increased plugin version in package.json

* Added topic subscription/unsubscription

* Removed some empty lines

* Removed GCM files and added FCM files

* Changed code to work with FCM

* Added hook and resource file to copy GoogleService-Info.plist

* Use CocoaPods

* Fix rebase errors

* Issue #689: Remove sender id from PushNotification init Android options

* 🐛 Issue #1188: Strings.xml google_app_id conflict with google-services.json

* Pin FCM to 9.8.0

* 🔧 Add browser platform back for FCM branch

* 🔨🔧⬆️ Use Babel to transpile ES2015 code

* 🔧 add tern to gitignore

* 🔖 Bumping plugin version to 2.0.0-rc1

* 🐛🐧📝⬆️ #1460: Build Issue Android

* Bumping plugin version to 2.0.0-rc2

* Added partial Android FCM support (#975)

* Modified plugin.xml to include FCM changes

* Plugin.xml changes for FCM

* Java changes for FCM

* Increased plugin version to 2.0.0

* Increased plugin version in package.json

* Added topic subscription/unsubscription

* Removed some empty lines

* Removed GCM files and added FCM files

* Added hook and resource file to copy GoogleService-Info.plist

* Use CocoaPods

* Fix rebase errors

* 🐛 Issue #1188: Strings.xml google_app_id conflict with google-services.json

* Updating CHANGELOG

* ✏️ fixing error in CHANGELOG

* Bumping plugin version to 2.0.0-rc2

* Updating CHANGELOG

* Added partial Android FCM support (#975)

* Modified plugin.xml to include FCM changes

* Plugin.xml changes for FCM

* Java changes for FCM

* Increased plugin version to 2.0.0

* Increased plugin version in package.json

* Added topic subscription/unsubscription

* Removed some empty lines

* Removed GCM files and added FCM files

* Changed code to work with FCM

* Added hook and resource file to copy GoogleService-Info.plist

* fixed registration and removed unused code

* Use CocoaPods

* Fix rebase errors

* Issue #689: Remove sender id from PushNotification init Android options

* Issue #689: Remove sender id from PushNotification init iOS options

* 🐛 Issue #1188: Strings.xml google_app_id conflict with google-services.json

* 🔧 add tern to gitignore

* 🔖 Bumping plugin version to 2.0.0-rc1

* Bumping plugin version to 2.0.0-rc2

* Remove hook and use resource-file tag to copy google services file

* Add resource-file way of copying google services files

* Bump requirements

* 🔧 Update cordovaDependencies

* 🔖 Bumping plugin version to 2.0.0-rc3

* 2.0.0-rc3

* Updating CHANGELOG

* Fixes 'framework not found GoogleToolboxForMac' linker error in 2.0.0-rc3 (#1715)

* Remove unused files (#1732)

* Remove GTM framework. (#1739)
@lock
Copy link

lock bot commented Jun 4, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 4, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Development

No branches or pull requests

3 participants