当收到Pusher的推送通知时,Android应用总是崩溃

时间:2019-09-23 07:50:45

标签: android kotlin pusher

我只是想从Pusher实现一个简单的Pusher光束通知。我从Pusher开始了快速入门。我配置并添加了依赖项和内容,但是每当我使用curl命令尝试发送通知时。它总是崩溃。我已经尝试了数小时的解决方案,但是找不到。这让我疯狂 。请帮忙。

这是我的代码在 MainActivitiy.kt

    PushNotifications.start(this, "instance id")
    PushNotifications.addDeviceInterest("hello")

这是日志:

 E/AndroidRuntime: FATAL EXCEPTION: Firebase-WrappedFirebaseMessagingService
Process: com.example.azda, PID: 22200
java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
    at android.content.ContextWrapper.getSystemService(ContextWrapper.java:562)
    at com.google.firebase.messaging.zzd.zza(com.google.firebase:firebase-messaging@@20.0.0:10)
    at com.google.firebase.messaging.FirebaseMessagingService.zzc(com.google.firebase:firebase-messaging@@20.0.0:60)
    at com.google.firebase.messaging.zze.run(com.google.firebase:firebase-messaging@@20.0.0:2)
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
    at com.google.android.gms.common.util.concurrent.zza.run(Unknown Source)
    at java.lang.Thread.run(Thread.java:818)

1 个答案:

答案 0 :(得分:0)

我找到了。问题是当解决方案像在Java中那样使用getApplicationContext()时,我不应该使用applicationContext的kotlin语法。

仅花费10个小时来编写2行代码。感到如此一文不值,想自杀。该死的

相关问题