I'm currently trying to create a Flutter application that can vibrate users at a specific (not known) time caused by another user. My solution for the Android version was to enable push notifications using Firebase Cloud Messaging while also unoptimizing the battery (for the application). I heard the push notification when it's a high-priority payload will handle the App Doze (idle standby) and it works just fine on the android. I recently got push notifications working on the iOS version, but the notification doesn't seem to awaken the device (and allow it to listen for a change on Firebase Firestore so it can vibrate). One solution to this would be to run code (vibration API) if a push notification is received, but I'm not sure how to do this. Is there a way to make the application wake up from the suspended app state so it can check for changes on Firestore? Currently, it works when the app is backgrounded but that's not enough.
If it helps, here's my notification payload:
const payload: admin.messaging.Message = {
topic: newValue.lobbyCode,
notification: {
title: "Bzzzt!",
body: "You've been buzzed!",
},
apns: {
payload: {
aps: {
contentAvailable: true,
},
},
},
android: {
priority: "high",
},
};
I'm currently using contentAvailable: true
because I heard it could be used to solve this. I'm also making use of the vibration.dart
plugin and it seems to not give me access to full control of vibrations like I have on Android. On xcode's capabilities, I have backgroundfetch, background processes, remote messaging, and push notifications enabled. However, I haven't added anything specific to info.plist
in regards to these because I'm not sure background fetch and processes is the solution.
Edit: I learned that it is also suspended/not working when another app is opened after it (till you return to my app).
What I did was add the sound permission to the iOS side and upload a custom CAF file which was an empty sound.