How do you access OneSignal's database on Android & iOS in Flutter? - sqlite

I am using OneSignal in my Flutter application to receive notifications. I have created my own table within Flutter to save notifications but I cannot save messages that have been sent whilst the app has been terminated. However, I have found that the OneSignal package has it's own database installed on the device which captures everything no matter what state the application is in! So, to avoid duplicating data I want to use this database instead. It is located outside of the flutter app folder which is my issue (see image below).
How do I access this database? Does anybody know if it is the same on iOS (I haven't been able to check at this time).
Many thanks.

It's important to understand that if an app has been terminated, any onReceived handler will not be fired. We don't recommend using the local db at all. Your best bet is to use the respective notification extender services for each platform. Though you will have to write native code for this! Cheers
Edit:
ANDROID - NotificationExtenderService - This can be setup to receive silent notifications when your app is not running or to override how notifications are shown in the notification shade. See the Background Data and Notification Overriding section to set this up.

Related

Firebase messaging background handler not called when app is terminated (Flutter)

I am trying to update my app's badge count number of my flutter app when receiving push notifications when the app is terminated.
The Firebase messaging background handler works fine if the app is in the background but doesn't work when the app is terminated.
I have read in the documentation :
On iOS, if the user swipes away the application from app Switcher, it must be manually reopened again for background messages to start working again.
Does it mean that on iOS there is no way to update the badge count using the firebase background handler (by the logic you implement in the handler of course, just need the handler to be called) ?
Any app do this today so i wonder why it would not be possible with Firebase Messaging.
I have actually found a solution, by using a service extension in swift and passing data as payload server side, using content-available: true in python.
Here is the documentation i have followed to implement the notification server side.
Also, there is an ongoing bug / feature request for flutter and Firebase regarding this case.

How do I send a timed notification on React Native

I don't need a server or anything, but basically I want to do a scheduled notification locally.
I tried using react-native-push-notification but it says I need firebase?
I just want to schedule a notification when the app is opened for a certain time
If you want to use only local notification with react-native-push-notification and avoid using firebase, refer to this part of readme:screenshot of readme
Don't worry about IOS, this library won't be used there

Firebase Cross Platform Push Notification Plugin Duplicating MainActivity

I'm using the following plugin for implementing and handling FCM push notifications in my xamarin application and there's one little unaddressed problem I'm facing.
I was hoping someone else has already figured it out and could help me.
THE PROBLEM:
It seems to be duplicating my MainActivity although I have the LaunchMode set to SingleTop.
There's an event called OnNotificationReceived that's provided by the library.
This event fires as expected, only once, when the application is in the foreground.
When I minimize the application (let it run in the background), send a notification to the device and tap on the notification, it opens the application, as expected, but if I send another notification after that, while the application is in the foreground, The OnNotificationReceived Event is fired twice.
I've tried changing the NotificationActivityFlags property to SingleTop.
I've tried changing my MainActivity's Launch Mode to SingleTop
I tried running the sample application they've provided to check if its something that I'm doing wrong, and still the same thing happens.
Logging the issue in their Github repository
None of the above have worked.
The issue can be reproduced by:
downloading the sample from the repository, link provided above
replacing their google-services.json file with your own from the Firebase
console.
change the package name of the sample of the application to the one you
have registered on Firebase
following the steps above that I've mentioned
ADDITIONAL INFO
Version Number of Plugin: 1.3.0
Device Tested On: Huawei P8 Lite Android Version 6.0
Version of VS: Visual Studio 2019
Version of Xamarin: 3.4.0.1009999
Update:
Unfortunately, the method below has not proven successful after attempting to implement it, I should have thought of the fact that I'm still going to need the notification object for iOS, earlier.
Myself and the team are going to implement a way to keep track of the users platform on the server and send them a notification either with or without the notification based on their platform, since iOS handles FCM notifications differently from Android. For now we're going to use Google's Instance ID service to determine what platform existing users are on.
Workaround:
I hope this helps someone in the future, if not I hope someone can provide me with a better solution.
In order to have my cake and eat it, basically be able to keep the notification object in the payload instead of removing it and having to further customise the payload to display notifications just for iOS, I changed the MainActivity's (the activity thats launched when a user taps on the notification) Launch mode to SingleInstance. That way I can keep my notification object in the payload and not have to worry about the OnNotificationReceived event being triggered twice.

Firebase Cloud Messages Push Notifications

I have developed a simple android app using Firebase database to store stuff.
Now, I want to set up notifications for each time a button is clicked.
Each time the button is clicked, it will take some info from firebase (text mostly) and will send a notification to anyone who downloaded the app.
I understood that simply creating a notificationManager won't work as needed.
I also heard about Firebase Cloud Messaging but im pretty new to this so I must know what I should start learning to make that work out.
So, if you have any good tutorials or anything helpful, that would be great!
Thanks!
You need to receive for the FCM in android app. Refer this doc. And you need to can use database triggers in firebase cloud functions to send FCM notification, or you need to deploy a cloud http function to do so.

Synchronize application with firebase post push notification when application is suspended

I am in the beginning stages of developing a react native mobile application. I wanted to get insights on the following on a conceptual level relating to the below.
Say the application goes into the suspended state (as mentioned here) at which point there is no application code being executed. Subsequently, the server sends a push notification based on some changes to the data. It seems that (at least on IOS) there is a way to use push notifications to initiate a download in the background. My questions are:
Is there a way to initiate this download in react native post a push notification when application is suspended?
Is there a way to synchronize the Firebase data with the application post such a push notification while the application is running in background if (1) above is possible?
Any hints on these will be of great help. Thank you.

Resources