我正在尝试在Cordova应用程序中实现推送通知。我确实收到了推送通知,但当我单击它们时没有任何反应。单击日志时,我在日志猫中看到以下消息:
I/ActivityManager( 746): START u0 {flg=0x10000000 cmp=xx.xxx.xx/jp.wizcorp.phonegap.plugin.localNotification.AlarmHelper (has extras)} from uid 10185 on display 0
W/InputMethodManagerService( 746): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy@210f434 attribute=null, token = android.os.BinderProxy@9fef9f7
我正在使用以下插件进行推送通知 https://github.com/Wizcorp/phonegap-plugin-localNotifications
据我所知,这是相关的部分:
// Create onClick for toast notification
Intent onClick = new Intent(context, AlarmHelper.class)
.putExtra(AlarmReceiver.NOTIFICATION_ID, notificationId);
// Create pending intent for onClick
PendingIntent contentIntent = PendingIntent.getActivity(context, 0, onClick, PendingIntent.FLAG_CANCEL_CURRENT);
// Build Notification
Notification notification = new Notification.Builder(context)
.setSmallIcon(bundle.getInt(ICON))
.setContentTitle(bundle.getString(TITLE))
.setContentText(bundle.getString(SUBTITLE))
.setTicker(bundle.getString(TICKER_TEXT))
.setContentIntent(contentIntent)
.setVibrate(new long[] { 0, 100, 200, 300 })
.setWhen(System.currentTimeMillis())
.build();
从这里复制
我发现我必须在AndroidManifest.xml
文件中包含意图的活动。添加此行解决了它。
<activity android:name="jp.wizcorp.phonegap.plugin.localNotification.AlarmHelper" />
始终确保在 Intent 中引用活动时,该活动已包含在清单中。