I'm having a chat in my app with notifications about new messages being shown and I'm using OneSignal for this.
However if the chat is with the person and the notification is about the chat open at that moment, I'd like it to hide the notification (not completely mute though as I'm using it for the chat messages being added into the conversation as well).
Is this doable or do I have to do for example save the open chat into the database, then check whatkind of notification is to be sent based to the open chat? (which would of course cause many kinds of issues if the user just simply closes the app)
Should I somehow edit the state of:
OneSignal.shared.setNotificationOpenedHandler((OSNotificationOpenedResult result) {
}
Or is there another trick into this to achieve it?
I know this is an old question but if you do this: -
OneSignal.shared.setInFocusDisplayType(OSNotificationDisplayType.none);
after you've initialized OneSignal it should do what you want
Related
I am implementing a chat feature in my flutter app. I use FCM to send a notification when a new message comes. I propagate the FCM message to flutter local notification when the notification came while the app is in the foreground. My problem is I don't want to show the local notification when the user is actively chatting with the sender.
I have firebase messaging configuration in app.dart and I have another stateful widget to show the message details and chat. I will get fromUid from notification data. I have also open chat message UID's in the message details widget. I am trying to compare these two UIDs values from notification and message detail widget and if the UIds are the same don't notify.
I try using change notifier and RouteObserver but it's not working fine. I will love any help and recommendations.
I have implemented a similar feature in my app. This is what I did.
I am using flutter and hive for local storage.
Do this when entering chat view
Hive.box("settings").put("currentChatId", xxx)
And on popping the page, set it to null again
On receiving notifications, before showing local notification you can just use .get("currentChatId")!= null && id==notificationId to check if it should show it or not.
I'm trying to create a Chat App. When the app enters background and if he receives a message, then a notification must appear.
What I understand is that FIRMessaging.sendMessage() sends something to the cloud. But how the other device is gonna receive it ? It cant be continually looking for messages that are targetted to him...
I would like to understand how to use this fonction and what are the parameters to pass in it. So far and with the current documentation, I couldnt do it.
[[FIRMessaging message]sendMessage:(nonnull NSDictionary *)message
to:(nonnull NSString *)receiver
withMessageID:(nonnull NSString *)messageID
timeToLive:(int64_t)ttl;
What should I put in the receiver ? It's userId in firebase ? or what ?
In the exemples they talk about SENDER_ID + "#gcm.googleapis.com"
which confuses me cause it looks like it's either my Id or the Id of the firebase App..
I cant even figure out if i'm trying to send an upstream or downstream message (dont understand)
Well all I can say is that I really get my head around it...
https://firebase.google.com/docs/cloud-messaging/upstream#handle_upstream_message_callbacks_1
Thanks!
Firebase Cloud Messaging and Firebase Notifications (which is built on Firebase Cloud Messaging) handle this automatically for you. From the documentation of Firebase Notifications:
When your app is in the background on a user's device, notifications are delivered to the system tray. When a user taps on the notification, the app launcher opens your app. If you want, you can also add client message handling to receive notifications in your app when it is already in the foreground on the user's device.
I want to develop an iphone app ,in which user can send a common message (Broadcast Message) to unlimited (Select All Contacts) and send to all at one time (In single attempt ) .It's possible to share images or text you want through Whatsapp in a iOS app?
Any idea regarding this?
There's also a WhatsAppKit on Github now: Check Link
There is no way you can use Whats app into App up till now. If so than also i will suggest not to rely on that.
If you want to make an feature for to broadcast a text message or image the best way is to implement your own. You can do the following:
Use xmpp Protocol
Implement push notification to notify for new broadcast messages
Create API for sending/receiving text messages & image & call it when you get notification
For more guidance refer this : http://quickblox.com/developers/SimpleSample-chat_users-ios
Is it possible to tell user what were about recently received push notifications ? I mean, if user clicks cancel when push was received, there is a badge on the icon of my application, but that's all. I think this is not user friendly and such notifications have no sense. When user opens an application, he knows that there is something new in it, but don't know exactly what. Do I need to make some requests to my web server to have information about my last pushes or I'm missing something and there is another way ?
From the implementations of push notifications I've worked with so far, you'll need to make a call to your server when the app actually starts up in order for the app to know what the new information is. I don't believe there's any way to store received push notifications unless your app is opened and handling them in the app delegate. Otherwise if push notification is closed it's discarded.
In all the apps I've worked with that utilized push notifications there was a place in the app where all the recent notifications were displayed after a call to the server was made to get the whole list.
I know you can register to have alerts or not when you call the push notification API. However my problem is that I want a certain class of actions to have an alert notification while no alert notification for other class of action?
So for example, an alert should be shown when we send the notification "Heart rate dropping alert!". But no alert should be shown when we send the notification "downloading updated patient data", the app should just take the notification as an instruction to being download if it is launched. And simply ignore it if it is not launched.
How to implement this?
Check Silent Push Notifications for iOS 7.In the WWDC 2013's "What's New with Multitasking" presentation, there is a section about Silent Push Notifications.
You can embed custom JSON data in the push notification, look at The Notification Payload in the Apple docs.
Update: I don't think that quite answers your question. You can send a blank notification that has the effect of cancelling any previous push notification (including those from other applications). I'm not sure if the app gets notified of that when it is actually running. If it does you might be able to do that in conjunction with a custom JSON payload to achieve what you want?
{"aps": {"badge": 0}}
You probably know this already - you can't use a push notification to launch the app on the iPhone without the user seeing a popup (apps can never run in the background on the iPhone).
However, you can display a different popup message and include different JSON data in the notification. Then if the user presses the button to launch the app ("Start", or whatever you call the button on the right) that JSON data is passed into the app. Your app can then carry out a different action based on that data.
Not possible. Push notifications cannot initiate tasks - nothing can cause an app to execute without user action. Similar question to Can I use Push Notification for this. You can trigger a sound, a text alert, or a badge value. That's it.