Scheduled Notifications with Firebase and background running - ios

I want my Firebase to send scheduled push notifications to all the users of my application and if the app is in the background; run some code and send some stuff to the server.
I'm a bit lost because it's impossible to do so with the notification console from Firebase.
Then, I was interested in Firebase Cloud Messaging, but in the documentation, it says that the connection to FCM should be ended :
When your app goes into the background, disconnect from FCM
-Source
What can I do? Should I take a look at services like Parse? Any help is greatly appreciated.

Notification messages don't execute your application code when your app is in the background. All messages sent from the Firebase console are Notification messages. So you can't currently use the Firebase console for what you are describing.
However you can send Data messages from your app server which can trigger background execution of code. You will have to manage the scheduling yourself on your app server.

I solved my problem building a server where the user register his token (unique identifier) to a database. There is also a PHP script for sending push notifications. You can find all of this here.
I edited the PHP script to send a payload which contains :
["content-available"] = "1"
This payload will trigger what you want to do when your app is in the background.
I used a crontab on my server to regularly send push notifications.
The notification console from Firebase can send push notification but not silent push notification that we want in my case.

Related

Having trouble setting up push notifications for conversation messages

I am having some trouble setting up push notifications for conversations.
I followed this guide to setup push notifications to web, and I integrated with firebase but it looks like it's not sending the notifications to firebase?
I can see in the push notifications section in twilio console that it's creating the notifications but when I check the push notification reports in firebase I do not see it there. I have confirmed that firebase was integrated correctly because I can send test push notifications from the firebase console but when I send messages in twilio it does not send the push notifications through to firebase.
Feel free to ask for more info that you might need to help me solve this issue :)

Firebase push notifications stop working for some users

I have an iOS and Android app which uses Firebase Cloud messaging for push notifications. And PHP for back-end (to send requests to firebase).
Some users have a problem. If they reinstall the app from scratch, they get push notifications 1-2 days. Then they just stop to receive any push notifications.
I got their firebase tokens and tried to send notifications directly from Firebase console. And they don't get it. But Firebase tells me that push successfully sent.
Checked iPhone's settings - notifications are enabled.
Can someone help me? What should I do to understand where is the problem?

Automatically open app when receive push notification for FCM (Flutter)

I'm trying to make the app open automatically when it receive the push notification, i am using Firebase Cloud Messaging and i've already read here about the same problem but i don't quite understand on how to use it for flutter
It's not possible to automatically launch the app once a notification has been received from Firebase Cloud Messaging. As mentioned in the docs, payloads received while the app is in the background can only be handled when the user taps on the notification.

Notification - when app is killed

I have implemented AWS SNS push notification service.
We have an issue which is explained below :
Scenario :
We are trying to save the notification message we receive as a part of requirement.
When the app is killed (swipe out from recent apps) we are able to receive notification, also we are able to save the notification message when we open the message directly from the notification panel it works fine,but when we open the app directly the notification message is not getting saved.
In short we are not able to know if we had received a notification message if we directly open the app rather than clicking the message from the notification panel.
Is this default behavior ? or is there any work around for this ?
Have looked into many posts on about Push Notifications but haven't seen any threads pointing to this scenario.
This is a normal behavior, and there is no workaround.
If your app is killed by the user, it won't be able to run ANY code before it's manually launched again.
If it's manually launched from a notification, this notification's payload will be handled by your AppDelegate.
On top of that, don't forget that Push notifications are Best Effort. That means that they are not reliable, they can be heavily delayed or never delivered at all. Don't rely on Push notifications to achieve any critical work.
If you need to keep a copy of your notifications in-app, keep them server side and fetch them as you would do with any other object.
In order to execute code when the app is killed by the user you need to implement VOIP using PushKit framework provided by apple.
VOIP push unlike regular push notification enables the app to become active even if the app is killed by user.

How to start an iOS push notification from an in-app process

I'm building an app that plugs into a third-party service that will send messages to the iOS device. So far I've been unable to find any documentation on then starting off a push notification when the delegate method is fired to say that a new message has been received.
So far, I've got the app registering to receive push notifications and the delegate method firing, I'm just not sure how to connect the two together?
The app will have a minimum deployment of iOS 5.1 if that helps.
This is not how remote notifications work. Their main purpose is to notify application about some event. So application only receives remote notifications and note send them. So scenario is:
App is notified via
application:didReceiveRemoteNotification: //if running
or
application:didFinishLaunchingWithOptions: //if closed
According to notification payload you determine what exact action you need to perform. For example notification says that a new message was sent to the user. Then you need to send your custom request to the your server and get that new message.
I've discovered that in this case it is not push notifications that I want but local notifications instead.

Resources