如何发送单击时打开URL的GCM?

时间:2016-09-18 01:29:57

标签: push-notification google-cloud-messaging service-worker

我已经设置了订阅通知的服务工作者。当Chrome位于前台时,javascript控制通知内容,其FATAL EXCEPTION: main Process: com.my.app, PID: 30978 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.app/com.my.app.NavControllerActivity_}: java.lang.IllegalArgumentException: is not a constant in android.text.Layout$Alignment at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2416) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476) at android.app.ActivityThread.-wrap11(ActivityThread.java) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344) at android.os.Handler.dispatchMessage(Handler.java:102) at android.os.Looper.loop(Looper.java:148) at android.app.ActivityThread.main(ActivityThread.java:5417) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616) Caused by: java.lang.IllegalArgumentException: is not a constant in android.text.Layout$Alignment at java.lang.Enum.valueOf(Enum.java:200) at android.text.Layout$Alignment.valueOf(Layout.java:2017) at android.text.style.AlignmentSpan$Standard.<init>(AlignmentSpan.java:33) at android.text.TextUtils$1.createFromParcel(TextUtils.java:711) at android.text.TextUtils$1.createFromParcel(TextUtils.java:689) at android.os.Parcel.readCharSequence(Parcel.java:1659) at android.os.Parcel.readValue(Parcel.java:2261) at android.os.Parcel.readArrayMapInternal(Parcel.java:2592) at android.os.BaseBundle.unparcel(BaseBundle.java:221) at android.os.BaseBundle.containsKey(BaseBundle.java:269) at com.my.app.NavControllerActivity_.injectExtras_(NavControllerActivity_.java:87) at com.my.app.NavControllerActivity_.init_(NavControllerActivity_.java:46) at com.my.app.NavControllerActivity_.onCreate(NavControllerActivity_.java:39) at android.app.Activity.performCreate(Activity.java:6237) at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1107) at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2369) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2476)  at android.app.ActivityThread.-wrap11(ActivityThread.java)  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1344)  at android.os.Handler.dispatchMessage(Handler.java:102)  at android.os.Looper.loop(Looper.java:148)  at android.app.ActivityThread.main(ActivityThread.java:5417)  at java.lang.reflect.Method.invoke(Native Method)  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)  事件处理程序将在单击通知时打开网页。 (代码未显示)

但是当Chrome处于后台时,“通知”有效负载将用于通知内容(js未激活),当我点击通知时,它只会打开Chrome而不打开任何网页。

我可以忍受处理两个案例(Chrome是前景或不是),但点击它们需要在两种情况下都打开一个网页。

我正在考虑我的通知缺少某些参数,或者我需要我的js来收听Chrome打开时触发的服务工作者事件。但我找不到相关的事件清单。

发送通知的代码:

notificationclick

0 个答案:

没有答案