Nativescript-plugin-firebase: [FCM] Background notification bug when the app is on active and click background notification

Created on 29 Jul 2019  路  16Comments  路  Source: EddyVerbruggen/nativescript-plugin-firebase

Hello,
I'm stuck with the background notification. I've got an error (Unable to destroy activity) if I click background notification when the app is opened and while using... but is okay when the app is not opened.

thank you

KakaoTalk_Photo_2019-07-29-12-21-57

Most helpful comment

@sanghyunj5958 Hi, i have had the same issue recently and i have found a workaround. The workaround is to add android:launchMode="singleInstance" to NativeScriptActivity in AndroidManifest.XML so only one instance of the app will be created. Hope this helps.

All 16 comments

Plz help

Any updates on this? I have exactly the same problem.

Not yet...

Did you guys find a solution for this issue?

I'd love to help, but I need a repo I can clone and check the actual error on as the screenshot above is not related to the plugin it seems.

Note that I just tested this with the demo app in this repo and I don't see the error. Hence the request for something I can reproduce this with.

Hey @EddyVerbruggen, thanks in advance to take your time to help us.
First of all I didn't test/try/or reproduce this issue on iOS. This error is manly happening to me on Android so I don't know how it is working on iOS.

About the issue:
At first I thought it was happening due to the use of RadSideDrawer as application root, but it seems the error is happening during resume application event. I'll try to give your some steps to how I reproduce this issue on my environment and let us know if you find it.

So, with a notification showing on your status bar for your app you will open the application, with the app showing on your screen, you will find your message on your status bar and tap on it. The app instead of just come to the front seems to be restarted, and at this point we got the error.

As you can see on this screenshots my app is on view, I can see it through status bar. For me this is the only flow which give me this error.
Screenshot_20190827-111845
Screenshot_20190827-111857

ps: I have no logic associated with app resume, pause, close or any of these events that handle app life cycle.

iOS device is working fine with no issue.

If you get 3 notifications on your Android device and click one of the notification, you will open the app. and then when you click 2 of them (notification), the app will try to open again and will get this error.

@sanghyunj5958 I just tried making the demo app in this repo crash again with the suggestions you provided, but I can't. So it has to be something related to the difference between the demo app and your app(s).

So please give this a go:

git clone https://github.com/EddyVerbruggen/nativescript-plugin-firebase
cd nativescript-plugin-firebase/src
npm i  # just skip through any prompts as they don't matter
npm run demo.android

Then press the 'init' button at the top, then scroll down and press the 'add push handlers' button and 'get current token'. That should log the device token to your console.

Now copy-paste this to your console and replace YOUR_PUSH_TOKEN_HERE by the token you previously grabbed from the console.

curl -X POST --header "Authorization: key=AAAA9SHtZvM:APA91bGoY0H2nS8GlzzypDXSiUkNY3nrti4st4WOUs_w1A0Rttcx31U90YGv-p3U4Oql-vh-FzZzWUUPEwl47uvwhI4tB5yz4wwzrJA2fVqLEKZpDU42AQppYnU2-dsURqkyc9sKcjay2egWbfyNK2b-G2JQCqrLVA" --Header "Content-Type: application/json" https://fcm.googleapis.com/fcm/send -d "{\"notification\":{\"title\": \"My title\", \"text\": \"My text\", \"badge\": \"1\", \"sound\": \"default\"}, \"data\":{\"foo\":\"bar\"}, \"priority\": \"High\", \"to\": \"YOUR_PUSH_TOKEN_HERE\"}"

@EddyVerbruggen thank you for your help, I tried your demo app and has no issue. it would be the problem with Angular or RadSideDrawer..

@EddyVerbruggen Hello, I tried to execute it with "template-drawer-navigation-ng" template with only your plugin. and I've got a same error.

Please check the attached file below. I tried to find these error for 3 days.. and I couldn't T.T

template-drawer-navigation-ng.zip

image

@EddyVerbruggen Hi, I just tried to demo with "template-blank-ng" template, and I just wrote the code below
firebase.init({ onMessageReceivedCallback: (message: Message) => { console.log(Title: ${message.title}); console.log(Body: ${message.body}); // if your server passed a custom property called 'foo', then do this: console.log(Value of 'foo': ${message.data.foo}); } });

and

firebase.init({ onPushTokenReceivedCallback: function(token) { console.log("Firebase push token: " + token); } });

after I added your plugin... I also get the same error.

Please check this error. I'm attaching the demo file below

Thank you very much

template-blank-ng.zip

@sanghyunj5958 Hi, i have had the same issue recently and i have found a workaround. The workaround is to add android:launchMode="singleInstance" to NativeScriptActivity in AndroidManifest.XML so only one instance of the app will be created. Hope this helps.

@CslBing That seems to resolve the issue but do you notice a long delay before the app is resumed? I'm not sure if it is because something I am doing or not.

@CslBing That seems to resolve the issue but do you notice a long delay before the app is resumed? I'm not sure if it is because something I am doing or not.

Hi @tylerablake , no i haven't had any deplay when app is resumed in my app.

Was this page helpful?
0 / 5 - 0 ratings