在 gcmintentservice.java 中使用 onresume 函数
Using onresume function in gcmintentservice.java
问题:
当应用程序打开并且我们收到通知并单击通知时,我将用户重定向到相应的页面。我需要 GCMIntentService.java 文件
中的 onclick 通知事件
我用 ionic 构建了一个聊天应用程序。有多个组。现在,当消息来自不同的组时,我使用 hashmap 来增加我的计数,并且我显示文本,如您在 XXXX 组中有 X 条未读消息
我想使用 platforms/android/src/com/plugin/gcm/PushHandlerActivity 中的 on resume 功能。java
@Override
protected void onResume() {
super.onResume();
final NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
hmap = new HashMap<Integer, String>();
}
in platforms/android/src/com/plugin/gcm/GCMIntentService.java 所以当推送通知被点击时我重新初始化哈希映射并且计数从 0
开始
这是我的 GCMIntentService.java 将帮助任何需要执行类似功能的人
我就是这样实现的。在你的 PushHandlerActivity 文件中你需要清除 hashmap
/*
* this activity will be started if the user touches a notification that we own.
* We send it's data off to the push plugin for processing.
* If needed, we boot up the main activity to kickstart the application.
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Log.v(TAG, "onCreate");
boolean isPushPluginActive = PushPlugin.isActive();
processPushBundle(isPushPluginActive);
finish();
GCMIntentService.hmap.clear();
if (!isPushPluginActive) {
forceMainActivityReload();
}
}
问题: 当应用程序打开并且我们收到通知并单击通知时,我将用户重定向到相应的页面。我需要 GCMIntentService.java 文件
中的 onclick 通知事件我用 ionic 构建了一个聊天应用程序。有多个组。现在,当消息来自不同的组时,我使用 hashmap 来增加我的计数,并且我显示文本,如您在 XXXX 组中有 X 条未读消息
我想使用 platforms/android/src/com/plugin/gcm/PushHandlerActivity 中的 on resume 功能。java
@Override
protected void onResume() {
super.onResume();
final NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
notificationManager.cancelAll();
hmap = new HashMap<Integer, String>();
}
in platforms/android/src/com/plugin/gcm/GCMIntentService.java 所以当推送通知被点击时我重新初始化哈希映射并且计数从 0
开始这是我的 GCMIntentService.java 将帮助任何需要执行类似功能的人
我就是这样实现的。在你的 PushHandlerActivity 文件中你需要清除 hashmap
/*
* this activity will be started if the user touches a notification that we own.
* We send it's data off to the push plugin for processing.
* If needed, we boot up the main activity to kickstart the application.
* @see android.app.Activity#onCreate(android.os.Bundle)
*/
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
Log.v(TAG, "onCreate");
boolean isPushPluginActive = PushPlugin.isActive();
processPushBundle(isPushPluginActive);
finish();
GCMIntentService.hmap.clear();
if (!isPushPluginActive) {
forceMainActivityReload();
}
}