【发布时间】:2014-07-16 12:58:32
【问题描述】:
我已经使用 azure 移动服务将通知广播到 android 设备,我已收到所有通知。
但是如何通过使用唯一 ID(如 MAC-id 或 IMEI No(来自设备的任何唯一 ID))向特定设备发送通知。我已经看到 以下链接Here 但它使用了一些标签来获取通知。但我没有收到通知。
我的客户端代码是
private void registerForNotification() {
try {
NotificationsManager.handleNotifications(this, SENDER_ID, ClientNotificationHandler.class);
gcm = GoogleCloudMessaging.getInstance(this);
String connectionString = "Endpoint=sb://notifischeduler-ns.servicebus.windows.net/;SharedAccessKeyName=DefaultFullSharedAccessSignature;SharedKey";
hub = new NotificationHub("notifischeduler", connectionString, this);
if(Constant.DEBUG)
Log.d(TAG, "Hub Details >>> "+hub.getConnectionString()+" HUB Path >> "+hub.getNotificationHubPath());
registerWithNotificationHubs();
} catch (Exception e) {
e.printStackTrace();
}
}
@SuppressWarnings("unchecked")
private void registerWithNotificationHubs() {
new AsyncTask() {
@Override
protected Object doInBackground(Object... params) {
try {
hub.unregister();
String regid = gcm.register(SENDER_ID);
String[] devArray = {"ANDROIDMOBILE2".trim()};
if(Constant.DEBUG)
Log.d(TAG,"HuB RegID "+regid);
hub.register(regid,devArray);
} catch (Exception e) {
e.printStackTrace();
return e;
}
return null;
}
}.execute(null, null, null);
}
在devArray 我需要通过唯一标识。如何做到这一点?
感谢您的帮助!
【问题讨论】:
标签: android push-notification google-cloud-messaging android-notifications azure-mobile-services