cranberrygame / cordova-plugin-pushnotification-parsepushnotification

16 stars 16 forks source link

Crashing app when receiving a notification #1

Open dinhienhy opened 9 years ago

dinhienhy commented 9 years ago

Hi,

Thank you so much for helpful project. I tried to apply this plugin to ionic cordova application. But I got a user case which throw crash app:

When it opened, everything worked fine. It only crash app when user turn of app. Please give some advice to fix it.

Thanks,

Dabadvic commented 9 years ago

I am having the same issue, and also I got crashing messages from time to time.

Did you find any solution or the cause of this?

cristofer commented 9 years ago

I have also problems with that, with the message: Unfortunately, APP_NAME has stopped. When it happends in production, the debug message that is sent to Google says:

java.lang.RuntimeException: Unable to start receiver com.parse.ParseBroadcastReceiver: java.lang.RuntimeException: applicationContext is null. You must call Parse.initialize(Context) before using the Parse library. at android.app.ActivityThread.handleReceiver(ActivityThread.java:2555) at android.app.ActivityThread.access$1500(ActivityThread.java:151) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1417) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:155) at android.app.ActivityThread.main(ActivityThread.java:5536) at java.lang.reflect.Method.invokeNative(Native Method) at java.lang.reflect.Method.invoke(Method.java:511) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1074) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:841) at dalvik.system.NativeStart.main(Native Method) Caused by: java.lang.RuntimeException: applicationContext is null. You must call Parse.initialize(Context) before using the Parse library. at com.parse.Parse.checkContext(Parse.java:448) at com.parse.Parse.getApplicationContext(Parse.java:267) at com.parse.ManifestInfo.getContext(ManifestInfo.java:324) at com.parse.ManifestInfo.getPackageManager(ManifestInfo.java:328) at com.parse.ManifestInfo.getPackageInfo(ManifestInfo.java:358) at com.parse.ManifestInfo.deviceSupportsGcm(ManifestInfo.java:446) at com.parse.ManifestInfo.getPushType(ManifestInfo.java:212) at com.parse.PushService.startServiceIfRequired(PushService.java:222) at com.parse.ParseBroadcastReceiver.onReceive(ParseBroadcastReceiver.java:19) at android.app.ActivityThread.handleReceiver(ActivityThread.java:2543) ... 10 more

I have my window.parseSetup inside of .run(function($ionicPlatform) {, and I also tried in the index.html as the basic/advanced example showed here.

At the sametime Im using Parse Javascript, so I also have the Parse.initialize in the same section.

Any ideas?

Thanks!

cristofer commented 9 years ago

OK guys, I just solved the issue.

First of all, I'm using ionic (just in case):

I created a class called MyPush.java inside of src/..package../MyPush.java

The content is:

package my_package;

import android.os.; import android.app.Application; import org.apache.cordova.; import com.parse.Parse;

public class MyPush extends Application { @Override public void onCreate() { Parse.initialize(this, "APP_KEY", "CLIENT_KEY"); } }

Then in the AndroidManifest.xml , in the tag application:

< application android:hardwareAccelerated="true" android:icon="@drawable/icon" android:label="@string/app_name" android:name="my_package.MyPush" android:supportsRtl="true">

and that's all!

I hope it helps :)

Cheers

cranberrygame commented 9 years ago

@dinhienhy @Dabadvic @cristofer

Fixed android crash issue. Thanks

Kunze commented 8 years ago

Why dont you write this in the description?

addiakogiannis commented 8 years ago

Problem still exists. How can I check if a device is already registered?