• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

How to subscribe multiple device token for FCM HTTP v1 API using coldfusion

New Here ,
Sep 19, 2024 Sep 19, 2024

Copy link to clipboard

Copied

In ColdFusion, we generated an OAuth token to send notifications. However, due to the limitations of FCM HTTP v1, we cannot send notifications to multiple devices at once. To overcome this, we found a solution: using a TOPIC to subscribe device tokens. We attempted to subscribe multiple tokens using the FCM SDK.

We included all the necessary dependent JAR files for subscribing, but it throws an error.

We are using ColdFusion 2023.

 

Here’s a simplified version of what we’re trying:

<cfset FirebaseAdmin = createObject("java", "com.google.firebase.FirebaseApp") /> <cfset FirebaseMessaging = createObject("java", "com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin) />

<cfset registrationTokens = ["token1", "token2", "token3"] />

<cfset response = FirebaseMessaging.subscribeToTopic(registrationTokens, topic) />

However, we’re getting an error when trying to subscribe the tokens.

Could anyone please provide a solution?

Views

789

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 19, 2024 Sep 19, 2024

Copy link to clipboard

Copied

Can you share all the details of the error?

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2024 Sep 19, 2024

Copy link to clipboard

Copied

Getting below error

com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor

We searched for this soltuion. It is something related to guava jar file. But we tried with almost all the version guava jar file. But still shows the error.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 19, 2024 Sep 19, 2024

Copy link to clipboard

Copied

The error is not related to ColdFusion. I agree with you that it is an error coming from Google's Guava library.

 

What is the name/version of the Guava Jar files you are using?  You could download and copy the latest versions of the Jar files to ColdFusion's lib directory, and see if that helps.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2024 Sep 19, 2024

Copy link to clipboard

Copied

I have used guava-33.3.0-jre.jar library. It's a latest version. Also tried with older version.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 19, 2024 Sep 19, 2024

Copy link to clipboard

Copied

As an example, I have just done the following test:

  1.  Download firebase-admin-9.3.0.jar from maven.org (its release date is 2024-05-21 18:18).
  2.  Copy the file to ColdFusion 2023's lib directory.
  3.  Restart ColdFusion.
  4.  Launch the following code (which I borrowed from you) as a CFM file.
    <cfset FirebaseAdmin = createObject("java", "com.google.firebase.FirebaseApp")> 
    
    <cfdump var="#FirebaseAdmin#">​

    The code runs as expected. The result is:
    BKBK_0-1726754166467.png

     

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2024 Sep 19, 2024

Copy link to clipboard

Copied

<cfset FirebaseAdmin = createObject("java", "com.google.firebase.FirebaseApp") />
<cfset FirebaseMessaging = createObject("java", "com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin) />

<cfset registrationTokens = ["token1", "token2", "token3"] />


<cfset response = FirebaseMessaging.subscribeToTopic(registrationTokens, topic) />

We know that it's working and creating the object for this <cfset FirebaseMessaging = createObject("java", "com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin) />  when we are caliing FirebaseMessaging.subscribeToTopic(registrationTokens, topic) method in response we are getting HTTP 500 :: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor

We want soltuion for this.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 20, 2024 Sep 20, 2024

Copy link to clipboard

Copied

quote "com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin) />  when we are caliing FirebaseMessaging.subscribeToTopic(registrationTokens, topic) method in response we are getting HTTP 500 :: com.google.common.util.concurrent.MoreExecutors.directExecutor()Ljava/util/concurrent/Executor


By @Piyush32537068gy36

 

As I said before, given that your question is about Firebase Messaging, you would probably be better off asking it in a Google Firebase forum.

 

In any case, shouldn't that line be "com.google.firebase.messaging.FirebaseMessaging").getInstance()" instead of "com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin)"? I ask because I can see the following in https://firebase.google.com/docs/cloud-messaging/cpp/topic-messaging :

BKBK_0-1726834450667.png

 

Your code passes the variable topic as an argument to subscribeToTopic. Question: is the value of topic a string?

 

  

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 20, 2024 Sep 20, 2024

Copy link to clipboard

Copied

Thanks for the reply. I will check it in detail and let you know

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 20, 2024 Sep 20, 2024

Copy link to clipboard

Copied

Test:

What do you get when you modify the code as follows?

<cfset FirebaseAdmin = createObject("java", "com.google.firebase.FirebaseApp") />
<cfset FirebaseMessaging = createObject("java", "com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin) />

<cfset registrationTokens = ["token1", "token2", "token3"] />

<!--- Temporary test code --->
<cfdump var="#FirebaseMessaging#" label="FirebaseMessaging" abort="true">

<cfset response = FirebaseMessaging.subscribeToTopic(registrationTokens, topic) />

If a variable is dumped, please share a printscreen of it.

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 20, 2024 Sep 20, 2024

Copy link to clipboard

Copied

Piyush32537068gy36_0-1726836467807.png

Plese refer the attach screenshot

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 20, 2024 Sep 20, 2024

Copy link to clipboard

Copied

The screenshot suggests that the HTTP 500 error is caused by the line

<cfset FirebaseMessaging = createObject("java", "com.google.firebase.messaging.FirebaseMessaging").getInstance(FirebaseAdmin) />

So, what happens when you run the following test?

 

<cfset FirebaseAdmin = createObject("java", "com.google.firebase.FirebaseApp") />
<cfset FirebaseMessaging = createObject("java", "com.google.firebase.messaging.FirebaseMessaging").getInstance() />

<cfset registrationTokens = ["token1", "token2", "token3"] />

<!--- Temporary test code --->
<cfdump var="#FirebaseMessaging#" label="FirebaseMessaging" abort="true">

<cfset response = FirebaseMessaging.subscribeToTopic(registrationTokens, topic) />

 

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 19, 2024 Sep 19, 2024

Copy link to clipboard

Copied

Will it work on Coldfusion 2021? When we execute the code below 

 

<cfset FirebaseAdmin = createObject("java", "com.google.firebase.FirebaseApp")>
<cfobject action="create" type="java" class="com.google.firebase.FirebaseApp" name="obj">
<cfdump var="#obj#" label="obj">
 

we got the error "Object instantiation exception.".  please advise

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Sep 19, 2024 Sep 19, 2024

Copy link to clipboard

Copied

Yes, it work in Coldfusion 2021.

But you wana download this firebase-admin-9.3.0 jar file and paste into coldfusion\lib folder

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Explorer ,
Sep 21, 2024 Sep 21, 2024

Copy link to clipboard

Copied

Thanks. I downloaded the above  firebase-admin-9.3.0 jar file and got the below error

jibinanto40792294_0-1726936967593.png

Then I got a fix to add dependency jar files so i added below jar files

jibinanto40792294_1-1726937175258.png

Then i got the response as 

jibinanto40792294_2-1726937224342.png

 

Thanks @BKBK. It helps me a lot.

 

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Expert ,
Sep 21, 2024 Sep 21, 2024

Copy link to clipboard

Copied

LATEST

Hi @jibinanto40792294 , thanks for the update.

 Piyush's problem is different from yours. As a result, it is confusing to have two separate discussions here. Could you therefore continue your discussion in your own thread?

That will help anyone who comes here to look for answers to a question similar to yours.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation