Local Notifications creations in chatting application when app in foreground - ios

How can we create local notification in IOS when app in foreground.I am creating chat app where two persons are chatting while third person interfere then the message which will be sent by third person should be shown in notification like whats app .Can any one please help me ?

First you receive the chat message . Then you determine whether the message received is from the person whom you are currently chatting with or third person. When you have determined that the message received is from third person, you use UILocalNotification class in iOS to create notification. For code help, please post your code too.

Related

Implementing push notification in a chat app

I am building a chat feature using firebase Realtime database where an integer variable stores a number (int online) which when a chat is opened by person A it adds 1 to the database and then if another person B comes online and opens the chat then it adds another 1. So, if the number is 2 I know that both are online and active in the chat app so no need to send push notification.
But the issue that I am facing now is that if a user closes the app without pressing the in-built back button of the chat app (which when pressed subtracts 1 and becomes 0 when both users are inactive), then the number in the database is not changed which causes error in the push notification logic as when Person A sends a message, the code assumes Person B is online. How could this be solved? Please someone help me understand how push notifications generally work?
First off all sending push notifications is completely FREE. The only costs are made by the the backend (cloud functions) that executes the code to send them.
Secondly. If your users are in the app no push notifications will be shown. Even if you would like to show some in your app you would need to handle the onMessageReceived to show something to the user while he is in the app.
That means there is no need for you to do the thing you try to do. Just send all messages as if no user is in the app. It would even cost you more to check for each user if he is online or not and send the messages only if he is offline than just to send them to everyone.
I would recommend to read the docs a little bit to get a deeper understanding of FCM and if you have any specific questions we can all help you with it :)

How to restrict the some iOS Push Notification message to user while app is background?

I am working on iOS application, it contains one task about to restrict the some Push notification to user when our app is in background.
consider this example if user have 4 types push notification of our
project like:
Some one sent Friend request.
Some one like his comment.
Some one share his comment.
Some one send message to user.
if user did want to push notification for Type 1 and 4 without using of server side script while our app is in background?.
Note: how to handle the push notification message of our application before it add in notification centre?

Sending notifications in messaging apps_Firebase

I used firebase to create a messaging channel between two users that are chatting with each other. Assuming that you send someone a message and their phone is locked, the app should be able to send notifications (such as whats seen below) but instead it would say something like, "Bobby just you a new message". What's the name of that kind of notification and how is it normally used with messaging apps?

How to "Group/Collapse" multiple notifications in the notification center if come from same converstation on iOS

On Android, when supplying the same id in two calls to NotificationManager.notify, only one notification will be shown in the notification drawer.
But how to do it on iOS
Thanks
Notifications on iOS are not designed to be grouped/collapsed or replaced by other notifications. Just check other messenger apps, the convention is to have a separate notification for each message, contrary to Android. Also a message doesn't get replaced by a new message in the same conversation. The functionality that Android provides here simply doesn't exist in iOS.
What you could do instead is, to send silent notifications ("push-to-sync") and handle the grouping/replacing on client side, since you have more control over local notifications (e.g. you can remove single local notifications, but not single remote notifications). But keep in mind, if the app was force quit, it won't be woken up to process the silent notification.
I think your best option is to stick to the convention and don't group/replace notifications.
about iOS you have to understand many things about the push notification
first it is not part of your app, in iOS it is separate application called notification centre that your app add itself to it so when APNS send a notification it send it to the notification centre in your iPhone not to your app.
so what you need to do will be in the server side not in the mobile side
for example let's say it is a chat application
the server side should check if the message is sent from the same user
the badge count should remain the same and not to notify APNS with new count
and also in the server side
the server will check if the message from the same user to send only sound notification not text or if the server got many message at once from the same user send the text with got many message from same user
but all of that is just work around as something like this is not provided yet in iOS may be in iOS9 as it become more open and not like previous versions
good luck

Parse.com - Send message from Parse.com to iOS app, not like push notification

I'm developing new iOS app using Parse.com, which uses to chat between two users. What is my problem is, when User A sends message to User B, it will store in Parse.com custom class object. But I want to know, how the Parse.com let to know the User B about he received message from User A. We can fetch from User B app with some frequent time. But this is not feasible way.
So, Is there any option that parse.com will send message to specific user who received message recently? I don't want to user Push notification for this, because push notification is different concept and also not reliable.
Thanks,
Vijay.
What you are asking for is exactly what Push Notifications are for. Your only other option is polling for changes.
If you find Push Notifications unreliable you would need to implement a combination of push + polling.
There are some other technologies out there, but they're not options with Parse without a lot of middle-ware.

Resources