EddyVerbruggen / nativescript-plugin-firebase

:fire: NativeScript plugin for Firebase
https://firebase.google.com
MIT License
1.01k stars 448 forks source link

IOS app crashes after push notification confirmation #488

Open ryanzaatari opened 6 years ago

ryanzaatari commented 6 years ago

I have been struggling for couple of days now from a similar issue, I have the latest release of this plugin 4.1.1

here's my package.json file

{ "description": "Makhzoumi Foundation public application", "license": "SEE LICENSE IN ", "readme": "----NO DATA AVAILABLE----", "repository": "", "nativescript": { "id": "com.makhzoumifoundation.general", "tns-android": { "version": "2.5.0" }, "tns-ios": { "version": "2.5.0" } }, "dependencies": { "nativescript-cardview": "^1.3.2", "nativescript-carousel": "^2.4.2", "nativescript-floatingactionbutton": "^2.2.7", "nativescript-intl": "^3.0.0", "nativescript-loading-indicator": "^2.3.2", "nativescript-orientation": "^1.6.1", "nativescript-phone": "^1.3.0", "nativescript-plugin-firebase": "^4.0.6", "nativescript-pulltorefresh": "^1.1.10", "nativescript-sqlite": "^1.1.7", "nativescript-statusbar": "^1.0.0", "nativescript-telerik-ui-pro": "file:///Users/ryanzaatari/Documents/Development/NativeScript/nativescript-ui-pro.tgz", "nativescript-theme-core": "^1.0.4", "nativescript-toasts": "^1.0.3", "tns-core-modules": "^2.5.2" }, "devDependencies": { "babel-traverse": "6.24.1", "babel-types": "6.24.1", "babylon": "6.17.0", "lazy": "1.0.11" } }

here's the crash report from firebase console

Exception name: EXC_BAD_ACCESS / KERN_INVALID_ADDRESS 1 NativeScript 4389574508 + 137068 2 NativeScript 4389573848 + 136408 3 NativeScript 4389625060 + 187620 4 NativeScript 4398674648 + 9237208 5 NativeScript 4398678448 + 9241008 6 Foundation -[__NSObserver _doit:] + 36880 7 CoreFoundation __CFNOTIFICATIONCENTER_IS_CALLING_OUT_TO_AN_OBSERVER__ + 868648 8 CoreFoundation _CFXRegistrationPost + 865992 9 CoreFoundation ___CFXNotificationPost_block_invoke + 865324 10 CoreFoundation -[_CFXNotificationRegistrar find:object:observer:enumerator:] + 1378800 11 CoreFoundation _CFXNotificationPost + 41948 12 Foundation postQueueNotifications + 378060 13 CoreFoundation __CFRUNLOOP_IS_CALLING_OUT_TO_AN_OBSERVER_CALLBACK_FUNCTION__ + 956596 14 CoreFoundation __CFRunLoopDoObservers + 946796 15 CoreFoundation __CFRunLoopRun + 947968 16 CoreFoundation CFRunLoopRunSpecific + 33492 17 GraphicsServices GSEventRunModal + 44928 18 UIKit UIApplicationMain + 472540 19 NativeScript 4398678080 + 9240640 20 NativeScript 4398673432 + 9235992 21 NativeScript 4398672176 + 9234736 22 NativeScript 4389459192 + 21752 23 NativeScript 4395964556 + 6527116 24 NativeScript 4395998996 + 6561556 25 NativeScript 4395999012 + 6561572 26 NativeScript 4395972612 + 6535172 27 NativeScript 4395578008 + 6140568 28 NativeScript 4395434548 + 5997108 29 NativeScript 4396875376 + 7437936 30 NativeScript 4389526752 + 89312 31 NativeScript 4397449420 + 8011980 32 NativeScript 4396001520 + 6564080 33 NativeScript 4395999012 + 6561572 34 NativeScript 4395999012 + 6561572 35 NativeScript 4395999012 + 6561572 36 NativeScript 4395972612 + 6535172 37 NativeScript 4395578008 + 6140568 38 NativeScript 4395434548 + 5997108 39 NativeScript 4396875580 + 7438140 40 NativeScript 4397432156 + 7994716 41 NativeScript 4389493232 + 55792 42 NativeScript 4389756244 + 318804 43 makhzoumifoundation 4378287836 + 24284 44 libdyld.dylib start + 5480

I don`t know if this helps, but I cannot find a "firebase.ios.js" file in my project ? If what I've provided is not enough please let me know what else do I need to include here.

Below is my firebase.nativescript.json file:

{ "using_ios": true, "using_android": true, "remote_config": false, "messaging": true, "crash_reporting": true, "storage": false, "facebook_auth": false, "google_auth": false, "admob": false, "invites": false }

ryanzaatari commented 6 years ago

@EddyVerbruggen

Update: I tested with couple of older versions of the plugin, namely 3.9.2 and 4.0.0 where it doesn't cause the app to crash upon confirming notification request, but notifications are not received, although token is received.

While for example version 4.1.1 causes the app to crash (and I never receive the token) but when pushing a "user segment" notification from firebase console, it is received on the device!

I really need to resolve this, appreciate any help!

AmithRamesh commented 6 years ago

Hi @EddyVerbruggen, Is this issue fixed, I am facing the same issue on iOS. App crashes while opening notifications received in background mode. I am using the plugin version 5.1.2. Please help.

EddyVerbruggen commented 6 years ago

@AmithRamesh You can try the demo app in this repo -- it never crashed on me.

AmithRamesh commented 6 years ago

@EddyVerbruggen, Thank you for the demo app. The problem was that I added console.log(json.stringfy(message)) in onMessageReceivedCallback() and that was throwing an error saying

ERROR Error: Uncaught (in promise): TypeError: JSON.stringify cannot serialize cyclic structures.

Seems to have resolved the issue after removing that console.log(json.stringfy(message)) line from the code. But had no idea about that error in the first place, and it only happens with iOS.

abhayastudios commented 6 years ago

It seems this line causes the circular reference while adding the data object.