Forums

OverviewFelgo 2 Support (Qt 5) › GCM permissions on android manifest?

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #23717

    jrrobles79

    I have followed the steps to add the notifications using gcm on my app and Im receiving the notifications on the console, but, the messages aren’t showed on the screen, so Im thinking I stillĀ  need something else, Im thinking I need a permission on the android manifest?

     

     GoogleCloudMessaging {
            id: gcm
            enabled: true 
            topics: ["topic-1"]
            onNotificationReceived: {
                console.debug("Received notification payload is",
                              JSON.stringify(data))
            }
            onRegistrationTokenReceived: {
            
               var oldToken = app.settings.getValue( properties.mGCMToken )
               if ( oldToken !== token){
                  // app.settings.setValue( properties.mGCMToken, token )
                   console.debug("GCM: new token set ")
                   console.debug(token)
                   app.settings.setValue( properties.mGCMTokenNew, token )
               }
    
            }
    
        }

     

    console:

    Received notification payload is {“alert”:{“body”:”great match!”,”title”:”Portugal vs. Denmark”},”message”:”Sample message for Android endpoints”}

    #23725

    jrrobles79

    I figure out , more or less, left this for another newbie like me:

     

    Add this on the manifest:

     

    <!– Creates a custom permission so only this app can receive its messages. –>
    <permission android:name=”YOUR_PACKAGE_NAME.permission.C2D_MESSAGE” android:protectionLevel=”signature” />
    <uses-permission android:name=”YOUR_PACKAGE_NAME.permission.C2D_MESSAGE” />
    <!– This app has permission to register and receive data message. –>
    <uses-permission android:name=”com.google.android.c2dm.permission.RECEIVE” />

     

    and the payload message, must be more like:

     

    {
      "GCM": "{\"notification\":{\"title\":\"test\",\"body\":\"test json\"}, \"data\": { \"message\": \"Sample message for Android endpoints\" } }"
    }

     

    Note: This works only for GCM and is going to be moved to Fire Cloud Messsag in the future

     

    Source:

    https://stackoverflow.com/questions/33516072/not-receiving-push-notification-using-gcm

    https://stackoverflow.com/questions/44621593/firebase-message-is-received-on-device-but-not-displayed-via-notification

     

     

     

Viewing 2 posts - 1 through 2 (of 2 total)

RSS feed for this thread

You must be logged in to reply to this topic.