Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Mobile and Embedded
  4. FCM data only notifications
Forum Updated to NodeBB v4.3 + New Features

FCM data only notifications

Scheduled Pinned Locked Moved Unsolved Mobile and Embedded
4 Posts 2 Posters 599 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • B Offline
    B Offline
    bludger
    wrote on last edited by bludger
    #1

    Hi all,

    I'm trying to receive data only notifications from FCM into our app using the QtCloudMessaging APIs. So far we've managed to receive these when the app is in the foreground but when the app is in the background or not running at all the notifications doesn't reach our C++ implementation.

    As per documentation we added the onNewIntent function into our activity:

    public class NotificationActivity extends org.qtproject.qt5.android.bindings.QtActivity
    {
        /**/
        @Override
        public void onCreate(Bundle savedInstanceState) {
            Log.d("QTAPP", "onCreate");
            super.onCreate(savedInstanceState);
        }
    
        @Override
        protected void onNewIntent(Intent intent) {
            Log.d("QTAPP", "A message was sent to this app while it was in the background.");
            Intent message = new Intent(this, MessageForwardingService.class);
            message.setAction(MessageForwardingService.ACTION_REMOTE_INTENT);
            message.putExtras(intent);
            message.setData(intent.getData());
            startActivity(message);
        }
    

    Changed our AndroidManifest.xml accordingly so our Activity will be used instead of the default one (QtActivity).

    For debugging we added some log lines into the QtCloudMessaging lib:

    
    void QCloudMessagingFirebaseClient::OnMessage(const::firebase::messaging::Message &message)
    {
        qDebug() << "QCloudMessagingFirebaseClient::OnMessage" << parseMessage(message);
    

    When logcat is running and we're sending our data only notification to the app (when it is in the background), we observe the following output:

    30108 D QTAPP: QCloudMessagingFirebaseClient::OnMessage "{\"from\":\"\",\"message_id\":\"\",\"data\":{\"key\":value}}"
    

    Indicating that the QtCloudMessaging is setup properly. But none of our C++ hooks are executed and we're not sure what is going wrong here.

    I suspect the Qt event loop isn't started upon receiving the message but I cannot figure out why.

    Someone able to help us?

    1 Reply Last reply
    0
    • Quang PhuQ Offline
      Quang PhuQ Offline
      Quang Phu
      wrote on last edited by Quang Phu
      #2

      Did you have your own function public void onMessageReceived(RemoteMessage remoteMessage) in your Activity
      For me, the message would come into that function when I push notification from Firebase.

      1 Reply Last reply
      0
      • B Offline
        B Offline
        bludger
        wrote on last edited by
        #3

        No, I don't have that. I assumed that the C++ bindings of FCM would take care of that. Isn't it that the case?

        1 Reply Last reply
        0
        • Quang PhuQ Offline
          Quang PhuQ Offline
          Quang Phu
          wrote on last edited by
          #4

          In my case, I think use that function is an easy case to get notification.
          You can try it if it fit your requirements

          1 Reply Last reply
          0

          • Login

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • Users
          • Groups
          • Search
          • Get Qt Extensions
          • Unsolved