An alert like whatsapp when app is in background in ionic - ionic-framework

I am using One Signal push notifications in my ionic app. I want to show an alert when i receive a notification when my app is in background.
I tried using the platform pause and remuse functionality to check for background and foreground and then generate an alert when app was in background using ionic alert controller but was not able to produce the desired result.
I want a pop up dialog box like one in whastapp when u receive a message.
Can anyone please suggest a solution to this.

There is no way to achieve what you're trying to achieve through the use of OneSignal alone. The OneSignal plugin for Ionic has two calls to action:
handleNotificationReceived() & handleNotificationOpened()
The first one is called when the notification is received and the app is in the foreground.
And the second is called when the app is launched from the notification.
You would need some other service to record when notifications are sent to see if there were any when the app was launched by itself. If you use OneSignal's REST API to send notifications yourself, you can record when a notification is sent, and then when the app is launched by itself, you can fetch missed notifications or notification count from your own server. That's just one way you can do it.
But OneSignal is a push notification service, which send notifications. Even if you did FCM yourself and went through the scenario you mentioned, the results would be the same.
It's not a OneSignal issue. It's the way notifications are designed.

Related

flutter notification chat quick reply

i have an application which is working fine. i add chatting to the app with notification. Any time users are chatting it send notification both in foreground and background.
my question:
how can i add notification reply just like WhatsApp. if a user send me message and i get the notification, i should be able to reply from the notification without opening the app.
Thanks
Have a look at this package: Awesome Notifications. It is still under construction but it will enable you to display custom notifications including a TextField that you can show when a real Push Notification got received.

How to set up custom behaviour when receiving a notification in Flutter

I have an app built in flutter and I am sending certain notification via firebase messaging to a given device. When that device receives the notification, I would like that there will be an alarm a bit like when you receive a phone call. I would like the alarm to go on until the user do not open the notification.
Is there an easy way to achieve this in flutter? I s it even possible?
Thanks

Get all notification messages (if any) when the app is opened using app icon

I was working with flutter and I managed to implement FCM push notification in the app. The FLUTTER_NOTIFICATION_CLICK click_action works fine.
But, I need to perform that similar action when the app is launched by clicking the app icon. Is there any method to do so?
Ultimate goal is to perform similar action when the app is launched by clicking the notification or by the app icon (from the app drawer). Please help me with this.
As far as I know, there is no way to get the received notification content when the app is opened using app icon in Flutter. I tried to find a method, but as of now, I am at zero.
Flutter with FCM supports only onLaunch and onResume click_action events for notifications. If you are able to write some native code, I think you may be able to do this. A simple work around I can give is that :
You can clear the notifications as soon as the app is opened using NotificationManager in Android. Here is the reference.
After that you can fetch the actual notification messages from your server(if there is one) and show it to the user.
This is not an accurate answer. But this is what I finally did. Not sure if this helps.
If you click and launch from notification
You can listen that 'onLaunch' method in firebaseMessaging.configure
But from 'app icon' is no way as far as I know.

Ionic 2 How to store Push notification in Notification board

I have an app that can receive several notifications at the same time.
I'm able to receive all of them (by setting style as inbox) but the issue is that when the user click on one notification, the app is opened and ALL the notification disappears... Is there a way that the device can keep the OTHER notifications in the notification list until the user click each of them?
I saw this working in other apps, but I'm trying to do it with Ionic2.
Thanks!

phonegap ios) is it possible distinguish push notification that user clicked?

I am using phonegap push notification plugin and all seems work fine. push comes without any problem.
But the problem is there is nothing I can do when app is back-grounded.
multiple push notifications can arrive when app is backgrounded. I can not expect which push
notification user going to click. Whatever notification user clicks, app will be resumed without
information of user selection. I have to trigger different events depanding on what nofitication
user selected. I need to know what notification user selected when app is resumed but don't
know how to... seems very tricky problem. is there anybody had same problem?
how did you guys handle this problem?
any help will be appriciated.
never mind...
I thought window.plugins.pushNotifiction.getPendingNotification would return all pending
notifications which arrived while app is background.
But getPendingNotification function only returns the notification that user selected on
notification center or mobile screen.
well... seems nice..
you can`t get all notification information which fire during application is off or app. is in background but, you can fetch user info shortly receive notification in native iOS app.
please follow this application:didFinishLaunchingWithOptions.
At first call of launch you can check for options and retrive the user-info.
for more info refer above link.