Android V4 Mobile Push Gateway Tutorial for Realtime Apps
1. 给项目添加FCM
2. 从FCM控制台获取API key
3. 将FCM 的API key放到PubNub管理控制台。保存。
4. 获取FCM的设备Token, 将设备与PubNub频道关联
// 将设备与频道关联
String fcmToken = FirebaseInstanceId.getInstance().getToken();
pubNub.addPushNotificationsOnChannels() .pushType(PNPushType.GCM) .channels(Arrays.asList(PubNubConfig.PUB_NUB_CHANNEL)) .deviceId(fcmToken) .async(new PNCallback<PNPushAddChannelResult>() { @Override public void onResponse(PNPushAddChannelResult result, PNStatus status) { LogUtil.d(Contant.DEBUG_LOG, "-->PNStatus.getStatusCode = " + status.getStatusCode() + " fcmToken = " + fcmToken); } });
https://www.pubnub.com/docs/tutorials/pubnub-access-manager
https://www.pubnub.com/docs/web-javascript/pam-security#Grant_access_to_manage_Channel_Group
https://stackoverflow.com/questions/39856692/android-pubnub-not-receiving-push-notification-via-fcm