【发布时间】:2015-09-11 13:11:45
【问题描述】:
我能够从服务器获取推送通知,但是当用户设备位置的经纬度发生变化时,我的应用应该会收到推送通知。
案例 1:
我必须将设备纬度和经度值发送到服务器,并且它必须在用户设备当前位置发生变化时发送推送通知。(从地方 A 移动到地方 B 以获取通知)即使应用程序在后台运行,应用程序需要配置系统操作系统才能推送。
案例 2:
我能够在单击推送通知时移动到活动,但我需要像如果我从服务器收到两个推送通知,单击第一个通知它必须采取 FirstActivity 并单击第二个推送通知采取 secondActivity。 如何识别要重定向到活动的推送通知。
在 GCMNotificationIntentService 中显示推送通知的代码:
private void createNotification(String msg){
Log.d(TAG, "Preparing to send notification...: " + msg);
NotificationManager notificationManager = (NotificationManager) this.getSystemService(Context.NOTIFICATION_SERVICE);
Notification notification = new Notification(R.drawable.offer, "GCM Notification", System.currentTimeMillis());
Intent notificationIntent = new Intent(this, FirstActivity.class);
notificationIntent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP | Intent.FLAG_ACTIVITY_SINGLE_TOP);
PendingIntent intent = PendingIntent.getActivity(this, NOTIFICATION_ID,notificationIntent, 0);
notification.setLatestEventInfo(this, "Message From GCM", msg, intent);
notification.flags |= Notification.FLAG_AUTO_CANCEL;
notificationManager.notify(NOTIFICATION_ID, notification);
NOTIFICATION_ID = NOTIFICATION_ID + 1;
}
【问题讨论】:
标签: android android-studio push-notification location