Mobile Backend Starter subscribeToCloudMessage will not work

后端 未结 4 1417
情书的邮戳
情书的邮戳 2020-12-10 22:15

When I use the subscribeToCloudMessage() function with CloudBackendMessaging.TOPIC_ID_BROADCAST as the topicId as is done in CloudBackendFragment.java everything works fine

4条回答
  •  轻奢々
    轻奢々 (楼主)
    2020-12-10 22:42

    It seems like the subscription ids are being generated using some algorythm that mainly uses the regid that is obtained when you first fire up the mobile backend starter app. To solve this issue when I had it I just called substring on the given regid and shortened it considerably but still left it long enough to guarantee some level of uniqueness.

    private static String doRegister(Context context) { String msg = ""; try { GoogleCloudMessaging gcm = GoogleCloudMessaging.getInstance(context); String regId = gcm.register(Consts.PROJECT_NUMBER).substring(0,16); msg = "Device registered, registration ID=" + regId;

    This method is located in the GCMIntentService.java file. Notice the

    .substring(0,16);

    Worked for me! just thought I'd share.

提交回复
热议问题