Custom Notification Depending on action - swift

SWIFT 3 / Firebase
app like instagram/Facebook
Notifications
I am working on letting users know when another user e.g. liked their post, made a friend request etc.
I set up everything for cloud messaging with firebase and can send bulk messages at all my devices.
Now I want to introduce notifications which contain the current user, the user who did the action and what happened.
Unfortunately I did not find anything about this despite the general implementing of firebase cloud messaging.
My questions are:
1: Do i have to structure a database (e.g. .child("notifications").child(userId).... ?
2: How do I get the token from the stranger user I address with the notification?
3: How can I make the input variable?
I am happy about all kinds of help!

Related

Xcode swift calendar event request between two Firebase users

I am currently building a messaging app using Firebase database. I was wondering if it is possible to send calendar event requests between two Firebase users.
So for example, the sender sends an event request to another user, and if the user accepts the request then that event is stored in both the sender and other users calendar.
Is this possible, possibly using eventkit?
Thanks
Yes, this is very possible, but completely up to you how you want to implement it.
I would first recommend a firebase function to tackle uploads (below) and then you can very easily send a notification to the other device using the same technique you would for a message.
You uploads could be done any number of ways. I think it is probably best to just mirror the behavior of a messaging app. For example, you have a node/document where you are savings the eventkit data. Upon writing to that node/document, your cloud function is triggered that notifies the receiving device.
I can provide more if necessary, but I would strongly suggest any tutorials about a firebase messaging/chat app but instead of writing a "message/text," you are writing your eventkit data.

Real-time notifications with Firebase & Ionic

NOTE : Don't say it's possible duplicate of this, Read through.
Think of a simple TASK Management application which can have n number of users. Say User A can create a task & assign it to User B. I want to show a notification to User B.
I am using Firebase as BAAS and following code-snippet prints on console only when there is a task assigned to User B. To simplfy, Users collection in Firebase has a node called tasksAssignedToThisUser array and callback function will be watching tasksAssignedToThisUser location. Whenever a new task gets added to that array, callback function gets executed. Here is the code snippet:
var rootRef = firebase.database().ref();
rootRef.child('users').child(loggedInUserID).child('tasksAssignedToThisUser')
.on('child_added', function (newMessageSnapshot) {
console.log('Someone assigned a task to this user.');
console.log(newMessageSnapshot.val);
});
Everything works fine until here.
What I have understood by reading Firebase docs & other post's on SO about Push notifications or Firebase Cloud Messaging is:
Firebase Notifications lets users easily send messages to reengage and
retain users, foster app growth, and support marketing campaigns.
Before you can write client apps that use Firebase Cloud Messaging,
you must have an app server that meets the following criteria:
...
You'll need to decide which FCM connection server protocol(s) you want
to use to enable your app server to interact with FCM connection
servers. Note that if you want to use upstream messaging from your
client applications, you must use XMPP. For a more detailed discussion
of this, see Choosing an FCM Connection Server Protocol.
This is definitely not what I want and maintaining a server for sending push notifications makes sense when bulk messages needs to be pushed to large number of devices. So I didn't name my question as Real Time Push Notifications.
I see a function being executed, which meets my use-case and I just want app to display a notification to the user in his mobile system tray on that callback function execution.
I am using Ionic 1 for developing app, completely new to Firebase and Ionic too. If there is a simple serverless approach that Firebase itself provides which can suffice my requirement, then I would be more than happy to hear about it.

What Kind of Service Do I Need to Use for Sending User-to-User Push Notifications on iOS

I need a little help with understanding what to look for when selecting a service to use for allowing my application's users to create accounts and send push notifications to each other. I do not have any backend service experience, except for with Parse, and I don't understand some of the functionality requirements.
I want users to be able to register an account and add other users. Then, I would like the users to be able to select specific users from their "friends" list in order to send a push notification to each selected user for a meeting. However, I honestly don't even know where to start.
It seems that many of the services that I have looked at are set up for sending targeted push notifications to groups of users from a dashboard (seemingly for marketing and other purposes).
I am completely new to servers and backends, except for a little activity with Parse, so can anyone recommend a direction for me to take for integrating such functionality in an iOS application that I am working on?
You can use mbaas providers like built.io backend, It provides push notification functionality on object creation event, and a set of ACL can be specified on these objects. This will act as a filter criteria as to who are the allowed to receive this push notification.
You can refer to their docs here https://docs.built.io

Send push notification to specific user?

I'm making an app where I want to be able to set a basic notification (title, message, fire date) and have been trying to figure out the best way to setup the notifications. I'm working with Swift 3 and Firebase 3.
I don't want to use local notifications because if the user is logged in on multiple devices I want it to push to all those devices.
Is there a way to do this with FCM where a user can set a notification to fire at a specific date and time and have it fire on all (iOS) devices logged in?
If FCM doesn't have this, is there another APK that does? I've looked at Batch briefly but I'm already using Firebase.
Thanks in advance!
If your main use case is to send a push notification to a single user for his multiple devices, I suggest you make use of Device Group Messaging on iOS. As per the docs, it is typically used for:
With device group messaging, app servers can send a single message to multiple instances of an app running on devices belonging to a group. Typically, "group" refers a set of different devices that belong to a single user.
When it comes to sending the notification on a specific date, I'm pretty sure you can set it up in the Firebase Console.
However, if you intend it to be sent from the server, you have to implement it yourself, since I think, there is no currently API available or a parameter you can set in the payload that can be modified for the message to be sent for a specific date.

How to check if a person in your iPhone contact list has an app installed?

I want to allow people to privately share data with each other using their contacts list to select people to share with. I'm planning on using Push Notifications to notify others that they have been shared with, but how can I handle those that do not have the app installed?
The cases are that I have their phone # and/or email. I can simply send them a message saying "X wants to share Y with you", but how can I determine if I need to send a Push Notification or an email/text?
If you're looking for API then you're out of luck. You can always collect this personal data server-side with agreement of your users. There you can also manage groups and other community relations.
Check here:
https://developer.apple.com/library/ios/#documentation/NetworkingInternet/Conceptual/RemoteNotificationsPG/ApplePushService/ApplePushService.html
The crux of it though will be that you will need to store a token when the device is registered anyway to be able to send notifications to them, so you can use that.
And using The Feedback Service alluded to in the documentation, you can remove the token, should it fail too often.
But, as rokjarc said, if you're expecting a third-party API to exist, you're pretty much out of luck. Apple ahs done most of the work for you already anyway.
When the app registeres for push notifications you need to pass additional data to your server. The user could input their own email/phone which will be sent to the server so that users can find each other. The email/phone can be stored alongside with the push token. When someone wants to share something, you would search the corresponding push token in the database and send the notification through APNS. Note there can be multiple push tokens for one email or phone i.e. when a user has multiple devices.
The users of your app should be aware of the data which is stored on your server and should have the option to delete it. Also use the APNS feedback service to detect and remove invalid push tokens.