Search code examples
iosfirebasereact-nativefirebase-cloud-messaginglaunching-application

React Native Wake Up App Using FCM Push Notification


Is it possible to launch/waking up an app from background when push notification comes without required user click on notification tray? if possible then how? especially on IOS.. (sorry for bad English)


Solution

  • You cannot launch your app when push notification arrives without user interaction.

    But you can wake up your app when device receives push notification. To do so you have to add content-available key with value 1 in aps dictionary. For example

    {
       "aps" : {
           "content-available" : 1
       },
       "acme1" : "bar",
       "acme2" : 42
    }
    

    As you are using FCM to send push notification so it's payload will look something like this

    {
    "to" : "<device>",
    "priority": "high",
    "content_available": true, <-- this key is converted to 'content-available:1'
    "notification" : {
      "body" : "noti body",
      "title" : "noti title",
      "link": "noti link "
    }
    }
    

    The important part here is content_available and priority.

    And make sure that in project capabilities section enable Background modes and check remote notification.

    References: Local and Remote Notification Programming Guide, Stackoverflow link1, Firebase FCM