FCM http v1 API Question

2,529 views
Skip to first unread message

ZhiPeng Ren

unread,
Mar 2, 2023, 4:25:47 PM3/2/23
to Firebase Google Group
As per Google FCM suggestion, we'd like to use http v1 api to push app message, based on the migration guideline, we can find the example message schema which can be used to push message to one device per invocation, can we use this api to send message to multiple devices per invocation?

Arthur Thompson

unread,
Mar 2, 2023, 7:10:04 PM3/2/23
to fireba...@googlegroups.com
Hi ZhiPeng,

Sending to multiple tokens can be done in two ways:

1. Topics, have each token subscribed to a topic and you can send to all subscribers in a single request. Note topics are not private so do not use them for sending sensitive information.

2. The FCM HTTP v1 API supports HTTP/2 so you can send multiple requests across a single connection each request targeting a different token.

On Thu, Mar 2, 2023 at 1:25 PM ZhiPeng Ren <renzhip...@gmail.com> wrote:
As per Google FCM suggestion, we'd like to use http v1 api to push app message, based on the migration guideline, we can find the example message schema which can be used to push message to one device per invocation, can we use this api to send message to multiple devices per invocation?

--
You received this message because you are subscribed to the Google Groups "Firebase Google Group" group.
To unsubscribe from this group and stop receiving emails from it, send an email to firebase-tal...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/firebase-talk/377dd452-0614-4344-b9a4-86b271c981dcn%40googlegroups.com.

ZhiPeng Ren

unread,
Mar 3, 2023, 11:05:12 AM3/3/23
to Firebase Google Group
hi Arthur

Thanks for your support

Since it's our first time to use the FCM HTTP v1 API, could you advise where can i get the guideline about topics method which you mentioned in option one

As for option two ,does that mean FCM HTTP v1 API do not support HTTP 1.1 post method?

Arthur Thompson

unread,
Mar 3, 2023, 12:02:19 PM3/3/23
to fireba...@googlegroups.com
Hi ZhiPeng,

You can find out more about topic messaging here.

Our HTTP v1 API does support HTTP/1.1 as well as HTTP/2, so you can send messages using either one. HTTP/2 provides the additional benefit of allowing multiple requests over a single connection.

ZhiPeng Ren

unread,
Mar 9, 2023, 11:42:01 AM3/9/23
to Firebase Google Group
hi Arthur

Thanks

we would use HTTP v1 API  and when we mint access token we got one question:

with refer to guideline ,we can find below java code to get access token by json file with Google library support,however we don't know what's the mean of the field SCOPES and where we can  get, could you advise?

private static String getAccessToken() throws IOException {
 
GoogleCredentials googleCredentials = GoogleCredentials
         
.fromStream(new FileInputStream("service-account.json"))
         
.createScoped(Arrays.asList(SCOPES));
  googleCredentials
.refreshAccessToken();
 
return googleCredentials.getAccessToken().getTokenValue();
}


Arthur Thompson

unread,
Mar 14, 2023, 7:35:56 PM3/14/23
to fireba...@googlegroups.com
Here are the FCM scopes.

Note if you use the default Google credentials the scopes are set for you.

ZhiPeng Ren

unread,
May 26, 2023, 2:34:35 PM5/26/23
to Firebase Google Group
hi Arthur
we can get the error:  Error getting access token for service account: connect timed out, iss: cvm...@citivelocity-456b8.iam.gserviceaccount.com
could you advise this error and how could we proceed?
Reply all
Reply to author
Forward
0 new messages