caffeinalab / ti.goosh

GCM/FCM module for Titanium.
MIT License
52 stars 34 forks source link

When app is closed: No valid root or current activity found for application instance #55

Closed hannta closed 6 years ago

hannta commented 7 years ago

When my app is completely closed and I click the notification, I get the "No valid root or current activity found for application instance"

Im using ti.goosh 2.0.6 and TiSDK 6.0.4. I have also tried to compile my app using TiSDK 6.0.1, but still getting the same error.

There is similar (closed) issue #47 but with no actual solution, other than using TiSDK 6.0.4?

progress44 commented 7 years ago

Make sure not to use the notification attribute when sending a notification through FCM. Always use data.

mitulbhalia commented 7 years ago

@hannta Provide your app flow because i got same error and solved it.

I have the app with login window so when i install the app first time and after logged in, i closed the login window and open next window that time when i clicked on notification i got same error and even callback function is not being called too.

So what i did is, instead of closing the login window, i hide it. That solves my issue.

mitulbhalia commented 7 years ago

@progress44 I still have one issue. Notification is not received when app is closed. All other aspects work well.

malhajj commented 7 years ago

Hello There,

First of all thanks for this great module, I really depend on it for several projects.

I have only one concern, is this issue, where the app is totally closed and notification is received, the user will click on that notification, but this module doesn't fire the callback.

If you want you can benefit from this module, https://github.com/arleyandrada/PushClient, which works fine with these scenarios.

The following is the snippet of code that I used in index.js in Alloy Project:

(function(){ var TiGoosh=require('ti.goosh'); TiGoosh.registerForPushNotifications({ callback: function (e) { alert('{message}'); var data = JSON.parse(e.data || ''); if (data.recipeId != -1 && e.inBackground) { Alloy.createController('/recipeDetails', { id: data.recipeId }).getView().open(); } }, success: function (e) { console.log('Notifications: device token is ' + e.deviceToken); Titanium.App.Properties.setString("token", e.deviceToken); }, error: function (err) { console.log(err); } }); })();

Kindly, I'm waiting for your replay to check if this can be resolved soon, or I should work on another solution until this is fixed.

Thanks again.

progress44 commented 7 years ago

While we're working on a solution for this issue, one possible way to avoid this is to check with the server for unopened notifications.

This should provide a temporary fix

Lenndev commented 7 years ago

@progress44 any status update yet?

progress44 commented 7 years ago

The issue is still open. Try the solution above

Lenndev commented 7 years ago

@progress44 thnx for your reply. for now i used the PushClient module @malhajj suggested. It works great in all cases. Hope you can solve the problems in ti.goosh.

Sofianio commented 6 years ago

Any fix yet? i'm getting the same error using ti.goosh 4.0.0 with TiSDK 7.0.1

kopiro commented 6 years ago

Hey guys, issue solved :) https://github.com/caffeinalab/ti.goosh/commit/22924ee861ae3e05f6fb2b2710db34521f0a8d4e

Sofianio commented 6 years ago

I've just tested it (4.1.0) and everything works like a charm wether the app is opened, in background, closed or killed, thanks a lot @kopiro

But I did find the bug where if click the notification i get the popup "Restart Required" infinite times, luckily i already encountered this bug back in 2015 the solution is to add the following to tiapp.xml <property name="ti.android.bug2373.finishfalseroot" type="bool">true</property> And everything is in order :)

kopiro commented 6 years ago

HI @Sofianio, did you get this error on every device and every time your clicked on the tray?

Sofianio commented 6 years ago

@kopiro Here are my test results:

I hope this helps.