timanrebel / Parse

Appcelerator Titanium module for the Parse SDK
MIT License
47 stars 31 forks source link

PushNotification not open app #32

Open DouglasHennrich opened 9 years ago

DouglasHennrich commented 9 years ago

Why when I click on the notification my app doesn't open ?

this is my index.js

Alloy.Globals.Parse.subscribeChannel('prixApp');

Alloy.Globals.Parse.addEventListener('notificationreceive', function(e) {
    console.log("notification: ", JSON.stringify(e));
});

Alloy.Globals.Parse.addEventListener('notificationopen', function(e) {
    Ti.API.log("notification: ", JSON.stringify(e));

    var data = Ti.App.Android.launchIntent.getStringExtra('com.parse.Data');
    if(data) {
        try {
            var json = JSON.parse(data);

            // Now handle the click on the notification
        }
            catch(_e) {}
    }
}); 

and this is my alloy.js

// Parse
Alloy.Globals.Parse = require('eu.rebelcorp.parse');
Alloy.Globals.Parse.start();

I'm something wrong or the app is not suppose to open when I click on the notification ?

Thanks 4.1.0.GA

DouglasHennrich commented 9 years ago

@FokkeZB @jvandijk @timanrebel anyone can help me please?

timanrebel commented 9 years ago

Have you had a look at this part of the README?

These events are only fired when the app is running. When the app is not running and a notification is clicked, the app is started and the notification data is added to the launching intent. It can be accessed with the following code:

    var data = Ti.App.Android.launchIntent.getStringExtra('com.parse.Data');

    if(data) {
        try {
            var json = JSON.parse(data);

            // Now handle the click on the notification
        }
            catch(e) {}
    }
DouglasHennrich commented 9 years ago

So when I click on notification when the app is not running it wont open it and display the message right away? I need to manual open the app to it show? Also I add these code inside the notificationopen listener? Or I just add these code on my index.js file?

Thanks @timanrebel

timanrebel commented 9 years ago

You should add it to your index.js, but I misunderstood your question. The notification should open the app, even when your app is not running. D you see any debug logging from the module in your debug loglevel?

DouglasHennrich commented 9 years ago

Indeed the app open when I click on the notification but it freeze on Splash Screen this is the debug log that I get when I click on the notification:

[DEBUG] onPushReceive: App is in foreground; trigger event 'notificationreceive'
[INFO]  ALERT: (KrollRuntimeThread) [32379,36350] notification: {"type":"notificationreceive","source":{"bubbleParent":true,"apiName":"Ti.Module","invocationAPIs":[],"_events":{"notificationreceive":[{},{}],"notificationopen":[{},{}]}},"push_hash":"caa9c8f8620cbb30679026bb6427e11f","alert":"testando","bubbles":false,"cancelBubble":false}
[INFO]  ALERT: (KrollRuntimeThread) [6,36356] notification: {"type":"notificationreceive","source":{"bubbleParent":true,"apiName":"Ti.Module","invocationAPIs":[],"_events":{"notificationreceive":[{},{}],"notificationopen":[{},{}]}},"push_hash":"caa9c8f8620cbb30679026bb6427e11f","alert":"testando","bubbles":false,"cancelBubble":false}
[INFO]  AppCompatDelegate: The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's
[INFO]  AppCompatDelegate: The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's
[INFO]  APSAnalyticsService: Analytics Service Started
[INFO]  APSAnalyticsService: Stopping Analytics Service
[DEBUG] onPushOpen: App was in background; resume the app and trigger 'notificationopen'
[INFO]  ALERT: (KrollRuntimeThread) [12780,49136] notification: {"type":"notificationopen","source":{"bubbleParent":true,"apiName":"Ti.Module","invocationAPIs":[],"_events":{"notificationreceive":[{},{}],"notificationopen":[{},{}]}},"push_hash":"caa9c8f8620cbb30679026bb6427e11f","alert":"testando","bubbles":false,"cancelBubble":false}
[INFO]  ALERT: (KrollRuntimeThread) [0,49136] Parse notification open:
[INFO]  AppCompatDelegate: The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's
[INFO]  AppCompatDelegate: The Activity's LayoutInflater already has a Factory installed so we can not install AppCompat's
[ERROR] TiLaunchActivity: (main) [129,49265] Android issue 2373 detected (missing intent CATEGORY_LAUNCHER or FLAG_ACTIVITY_RESET_TASK_IF_NEEDED), restarting app. br.com.feedbackbrasil.FeedbackActivity@2b1d8ba2
[DEBUG] AndroidRuntime: Shutting down VM
[ERROR] TiApplication: (main) [23,49288] Sending event: exception on thread: main msg:java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.feedbackbrasil/br.com.feedbackbrasil.FeedbackActivity}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features; Titanium 4.1.0,2015/07/06 11:15,d57aa7d
[ERROR] TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.feedbackbrasil/br.com.feedbackbrasil.FeedbackActivity}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
[ERROR] TiApplication:  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2314)
[ERROR] TiApplication:  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2386)
[ERROR] TiApplication:  at android.app.ActivityThread.access$800(ActivityThread.java:148)
[ERROR] TiApplication:  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1292)
[ERROR] TiApplication:  at android.os.Handler.dispatchMessage(Handler.java:102)
[ERROR] TiApplication:  at android.os.Looper.loop(Looper.java:135)
[ERROR] TiApplication:  at android.app.ActivityThread.main(ActivityThread.java:5310)
[ERROR] TiApplication:  at java.lang.reflect.Method.invoke(Native Method)
[ERROR] TiApplication:  at java.lang.reflect.Method.invoke(Method.java:372)
[ERROR] TiApplication:  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:901)
[ERROR] TiApplication:  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:696)
[ERROR] TiApplication: Caused by: java.lang.IllegalArgumentException: AppCompat does not support the current theme features
[ERROR] TiApplication:  at android.support.v7.app.AppCompatDelegateImplV7.ensureSubDecor(AppCompatDelegateImplV7.java:360)
[ERROR] TiApplication:  at android.support.v7.app.AppCompatDelegateImplV7.setContentView(AppCompatDelegateImplV7.java:237)
[ERROR] TiApplication:  at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:111)
[ERROR] TiApplication:  at org.appcelerator.titanium.TiLaunchActivity.checkInvalidLaunch(TiLaunchActivity.java:192)
[ERROR] TiApplication:  at org.appcelerator.titanium.TiLaunchActivity.checkInvalidLaunch(TiLaunchActivity.java:162)
[ERROR] TiApplication:  at org.appcelerator.titanium.TiRootActivity.onCreate(TiRootActivity.java:78)
[ERROR] TiApplication:  at android.app.Activity.performCreate(Activity.java:5953)
[ERROR] TiApplication:  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1128)
[ERROR] TiApplication:  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2267)
[ERROR] TiApplication:  ... 10 more
timanrebel commented 9 years ago

It looks like the module starts the app, but an error occurs while loading your app:

4.1.0,2015/07/06 11:15,d57aa7d [ERROR] TiApplication: java.lang.RuntimeException: Unable to start activity ComponentInfo{br.com.feedbackbrasil/br.com.feedbackbrasil.FeedbackActivity}: java.lang.IllegalArgumentException: AppCompat does not support the current theme features 
DouglasHennrich commented 9 years ago

Do you know what may causing this error:

this is my tiapp.xml android:

<android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest android:versionName="1.0.0" android:versionCode="100">
            <uses-sdk android:minSdkVersion="21"/>
            <uses-permission android:name="android.permission.INTERNET"/>
            <activity android:name=".FeedbackActivity" 
                android:label="Feedback Brasil" 
                android:theme="@style/Theme.Titanium" 
                android:configChanges="keyboardHidden|orientation|screenSize" 
                android:alwaysRetainTaskState="true" 
                android:launchMode="singleTask">
                <intent-filter>
                    <action android:name="android.intent.action.MAIN"/>
                    <category android:name="android.intent.category.LAUNCHER"/>
                </intent-filter>
                <intent-filter>
                    <action android:name="android.intent.action.VIEW"/>
                    <category android:name="android.intent.category.DEFAULT"/>
                    <category android:name="android.intent.category.BROWSABLE"/>
                    <data android:scheme="feedback"/>
                </intent-filter>
            </activity>
        </manifest>
    </android>

Thanks

jvandijk commented 9 years ago

@DouglasHennrich is there any specific reason that you enable the singleTask launchMode?

DouglasHennrich commented 9 years ago

I was trying to make custom url scheme to be able to open my app through another app but it failed ): I was following this tutorial: http://fokkezb.nl/2013/08/26/url-schemes-for-ios-and-android-1/

DouglasHennrich commented 9 years ago

@timanrebel can you post here your tiapp.xml so I can see your Android Section? Maybe I'm missing something and that is causing this error

timanrebel commented 9 years ago

@DouglasHennrich You don't need any special Android section for this module, but here is one from an app that uses this Parse module:

    <android xmlns:android="http://schemas.android.com/apk/res/android">
        <manifest android:installLocation="auto" android:versionCode="4" android:versionName="1.1.0">
            <uses-sdk android:minSdkVersion="14" android:targetSdkVersion="21" />
            <!-- This tells the Marketplace and the system what versions of Android your app supports -->
            <application android:debuggable="false" android:hardwareAccelerated="true" android:theme="@style/scDefault"/>
            <uses-permission android:name="android.permission.READ_CALENDAR"/>
            <uses-permission android:name="android.permission.WRITE_CALENDAR"/>
        </manifest>
    </android>

As you can see, nothing Parse related. You could even remove the whole Android section (just leave in the Parse keys)

DouglasHennrich commented 9 years ago

@timanrebel So I have no idea what is causing this problem =l Any suggestions? Thanks

0x6e69636f commented 8 years ago

When I click on a notification

If you have infos about events to listen to, or other stuff, it would be great ... thanks !