caffeinalab / ti.goosh

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

The app stuck on restarting the activity if the notification is clicked #101

Closed AhmedMSayed closed 6 years ago

AhmedMSayed commented 6 years ago

1- Receive a notification in the background. 2- Click on it.

TiLaunchActivity: (main) [39356,767231] Android issue 2373 detected (missing intent CATEGORY_LAUNCHER or FLAG_ACTIVITY_RESET_TASK_IF_NEEDED), restarting app. com.example.sample.SampleActivity@e50b29d

caioiglesias commented 6 years ago

how are your intent filters set up inside tiapp?

AhmedMSayed commented 6 years ago

I don't setup intent filter inside my application tag and if I set one it should be like this

<activity
                android:configChanges="keyboardHidden|orientation|fontScale|screenSize|smallestScreenSize|screenLayout|density"
                android:label="Sample"
                android:name=".SampleActivity">
                    <intent-filter>
                        <action android:name="android.intent.action.MAIN"/>
                        <category android:name="android.intent.category.LAUNCHER"/>
                    </intent-filter>
                </activity>
AhmedMSayed commented 6 years ago

Another error related to this

[ERROR] :  WindowManager:
[ERROR] :  WindowManager: android.view.WindowLeaked: Activity org.appcelerator.titanium.TiActivity has leaked window DecorView@965bf62[] that was originally added here
[ERROR] :  WindowManager:   at android.view.ViewRootImpl.<init>(ViewRootImpl.java:487)
[ERROR] :  WindowManager:   at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:365)
[ERROR] :  WindowManager:   at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:114)
[ERROR] :  WindowManager:   at android.app.Dialog.show(Dialog.java:445)
[ERROR] :  WindowManager:   at org.appcelerator.titanium.TiExceptionHandler.createDialog(TiExceptionHandler.java:201)
[ERROR] :  WindowManager:   at org.appcelerator.titanium.TiExceptionHandler$1.onCurrentActivityReady(TiExceptionHandler.java:102)
[ERROR] :  WindowManager:   at org.appcelerator.titanium.util.TiUIHelper.waitForCurrentActivity(TiUIHelper.java:192)
[ERROR] :  WindowManager:   at org.appcelerator.titanium.TiApplication.waitForCurrentActivity(TiApplication.java:820)
[ERROR] :  WindowManager:   at org.appcelerator.titanium.TiExceptionHandler.handleOpenErrorDialog(TiExceptionHandler.java:98)
[ERROR] :  WindowManager:   at org.appcelerator.titanium.TiExceptionHandler.openErrorDialog(TiExceptionHandler.java:60)
[ERROR] :  WindowManager:   at org.appcelerator.titanium.TiExceptionHandler.handleException(TiExceptionHandler.java:239)
[ERROR] :  WindowManager:   at org.appcelerator.kroll.KrollRuntime.dispatchException(KrollRuntime.java:538)
[ERROR] :  WindowManager:   at org.appcelerator.kroll.runtime.v8.V8Object.nativeCallProperty(Native Method)
[ERROR] :  WindowManager:   at org.appcelerator.kroll.runtime.v8.V8Object.callProperty(V8Object.java:75)
[ERROR] :  WindowManager:   at org.appcelerator.kroll.KrollProxy.handleMessage(KrollProxy.java:1200)
[ERROR] :  WindowManager:   at android.os.Handler.dispatchMessage(Handler.java:101)
[ERROR] :  WindowManager:   at android.os.Looper.loop(Looper.java:156)
[ERROR] :  WindowManager:   at android.app.ActivityThread.main(ActivityThread.java:6605)
[ERROR] :  WindowManager:   at java.lang.reflect.Method.invoke(Native Method)
[ERROR] :  WindowManager:   at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:999)
[ERROR] :  WindowManager:   at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:889)
m1ga commented 6 years ago

Did you try to add <property name="ti.android.bug2373.finishfalseroot" type="bool">true</property> to tiapp.xml?

AhmedMSayed commented 6 years ago

work fine with it @m1ga

AhmedMSayed commented 6 years ago

but this isn't the solution @m1ga Now the main screen has opened twice.

m1ga commented 6 years ago

But are you sure that it is a ti.goosh error? Bug2373 is a long time Appc "bug"

AhmedMSayed commented 6 years ago

1- Create a new application 2- Add the code below

var win = Ti.UI.createWindow({
    backgroundColor: '#ffffff'
});

var TiGoosh = require('ti.goosh');

TiGoosh.registerForPushNotifications({

    callback : function(e) {
        var data = JSON.parse(e.data || '');
        Ti.API.warn("Notification received: " + e.data);
    },
    success : function(e) {
        Ti.API.warn("Device Token received: " + e.deviceToken);
        subscribeToChannel();
    },
    error : function(err) {
        Ti.API.warn('Failed to register for push notifications! ' + err);
    }

});

function subscribeToChannel() {

    TiGoosh.subscribe({
        topic : "/topics/myTopic",
        success : function(e) {
            Ti.API.warn('Subscribed');
        },
        error : function(e) {
            Ti.API.warn('Error:\n' + ((e.error && e.message) || JSON.stringify(e)));
        }
    });

}

win.open();

3- Send new notification from server

screenshot_1519312639

PMistry123 commented 5 years ago

I am facing the sameApp stuck issue and getting following error in my console, Did you find any solution for this, please let me know?

[ERROR] : TiExceptionHandler: (main) [15128,88247] Not allowed to start service Intent { cmp=ca.wearecircus.bcc/com.radiusnetworks.ibeacon.IBeaconIntentProcessor (has extras) }: app is in background uid UidRecord{fe9fde7 u0a474 LAST bg:+1m3s223ms idle procs:1 seq(0,0,0)} [ERROR] : TiExceptionHandler: [ERROR] : TiExceptionHandler: android.app.ContextImpl.startServiceCommon(ContextImpl.java:1538) [ERROR] : TiExceptionHandler: android.app.ContextImpl.startService(ContextImpl.java:1484) [ERROR] : TiExceptionHandler: android.content.ContextWrapper.startService(ContextWrapper.java:663) [ERROR] : TiExceptionHandler: com.radiusnetworks.ibeacon.service.Callback.call(Callback.java:63) [ERROR] : TiExceptionHandler: com.radiusnetworks.ibeacon.service.IBeaconService.processRangeData(IBeaconService.java:533) [ERROR] : TiExceptionHandler: com.radiusnetworks.ibeacon.service.IBeaconService.finishScanCycle(IBeaconService.java:451) [ERROR] : TiExceptionHandler: com.radiusnetworks.ibeacon.service.IBeaconService.scheduleScanStop(IBeaconService.java:436) [ERROR] : TiExceptionHandler: com.radiusnetworks.ibeacon.service.IBeaconService.access$100(IBeaconService.java:62) [ERROR] : TiExceptionHandler: com.radiusnetworks.ibeacon.service.IBeaconService$2.run(IBeaconService.java:432) [ERROR] : TiExceptionHandler: android.os.Handler.handleCallback(Handler.java:789) [ERROR] : TiExceptionHandler: android.os.Handler.dispatchMessage(Handler.java:98) [ERROR] : TiExceptionHandler: android.os.Looper.loop(Looper.java:164) [ERROR] : TiExceptionHandler: android.app.ActivityThread.main(ActivityThread.java:6944) [ERROR] : TiExceptionHandler: java.lang.reflect.Method.invoke(Native Method) [ERROR] : TiExceptionHandler: com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327) [ERROR] : TiExceptionHandler: com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)

m1ga commented 5 years ago

@PMistry123 that sounds like a different issue and is related to the iBeaconService and not ti.goosh. Are you running on an Android 8+ phone? Check this: https://github.com/AltBeacon/android-beacon-library/issues/673 thread. Perhaps it will lead to a fix

cjadhav commented 5 years ago

Hi @AhmedMSayed @m1ga , did you find the solution..?? I am facing the same problem.

If I add the <property name="ti.android.bug2373.finishfalseroot" type="bool">true</property> then on background app restarts only when we open the notification.

Also if the app is in foreground while receiving notification the app restarts automatically. And I am not receiving notifications when app is closed.

Your help is highly appreciable.

Environment: Device: Android 9 Android One Power, TargetSDKVersion: 28, Ti SDK: 7.5.1