I have a setup very similar to this previous OP.
In short, I use the expo-server-sdk
to send out a notification, and I’m able to receive and handle this notification if my app is foregrounded or backgrounded. In the event that it is backgrounded, I use expo-task-manager
, again, as in the question that I linked to above.
This works as expected, however I needed a mechanism to bring my app to the foreground, or at least wake it up, if a user received an incoming call. I’m using react-native-callkeep
for all call-related functionality.
The OS in question is Android. I haven’t gotten to fully implementing this for iOS yet.
expo-task-manager
does not work if the app is terminated. It works if the app is either backgrounded or foregrounded, but if you quit/close the app, then expo-task-manager
does not fire (specifically Notifcations.registerTaskAsync
)
So, following the docs from react-native-callkeep
:
In some case your application can be unreachable :
- when the user kill the application
- when it’s in background since a long time (eg: after ~5mn the os will kill all connections).
To be able to wake up your application to display the incoming call, you can use https://github.com/react-native-webrtc/react-native-voip-push-notification on iOS or BackgroundMessaging from react-native-firebase-(Optional)(Android-only)-Listen-for-FCM-messages-in-the-background).You have to send a push to your application, like with Firebase for Android and with a library supporting PushKit pushes for iOS.
So I’ve installed @react-native-firebase/app
and @react-native-firebase/messaging
as per their documentation here and here.
After rebuilding my app, all notifications stopped coming in, even though I get a { status: 'ok' }
when attempting to send out a notification. It just doesn’t get delivered.
The only thing I haven’t done from the docs is specify any config plugins. This is because, apparently, they are included by default for @react-native-firebase/app
.
Uninstalling @react-native-firebase/app
and @react-native-firebase/messaging
solves the unreceived notifications problem, but it just brings me back to the original issue of needing a mechanism for waking the terminated app.
My app.config.ts
:
export default {
expo: {
name: '. . .',
ios: {
googleServicesFile: './GoogleService-Info.plist',
bundleIdentifier: 'com.me.app', // same as in google-services.json
'. . .'
},
android: {
googleServicesFile: './google-services.json',
package: 'com.me.app', // same as in google-services.json
'. . .'
},
plugins: [
'@react-native-firebase/app',
[
'expo-build-properties',
{
android: {
usesCleartextTraffic: true,
},
ios: {
useFrameworks: 'static',
},
},
],
'@config-plugins/react-native-webrtc',
'@config-plugins/react-native-callkeep',
'. . .'
],
runtimeVersion: {
policy: 'appVersion',
},
extra: {
eas: {
projectId: '. . .',
},
},
updates: {
url: '. . .',
},
},
};
What am I doing wrong here? Did I overlook something during the installation process or does @react-native-firebase
not play nice with expo-notifications
?