Skip to main content
Participating Frequently
September 19, 2024
Question

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

  • September 19, 2024
  • 2 replies
  • 1805 views

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?

    This topic has been closed for replies.

    2 replies

    jibinanto40792294
    Inspiring
    September 20, 2024

    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

     

    Participating Frequently
    September 20, 2024

    Yes, it work in Coldfusion 2021.

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

    jibinanto40792294
    Inspiring
    September 21, 2024

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

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

    Then i got the response as 

     

    Thanks @BKBK. It helps me a lot.

     

    BKBK
    Community Expert
    Community Expert
    September 19, 2024

    Can you share all the details of the error?

    Participating Frequently
    September 19, 2024

    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.

    BKBK
    Community Expert
    Community Expert
    September 19, 2024

    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.