Send notifications only to logged in users' devices via FCM [duplicate] - firebase-cloud-messaging

This question already has answers here:
How to target a logged user with FCM? [duplicate]
(1 answer)
Sending Firebase Push Notifications to Logged-in Users Only
(2 answers)
Closed 2 years ago.
I would like to send notifications (or at least make them readable) only to users that are logged in on their devices. I could on each login and signout edit the realtime database and let the function that sends out notifications check it, but I was wondering if there was a simpler way to do this.

Firebase Cloud Messaging has no knowledge of users, so any time you want to relate messages to users you will have write code to do this. What you're describing is indeed a common way of doing this: write the token to a database when the user signs in, remove it from that database when they sign out.
Also see:
Sending Firebase Push Notifications to Logged-in Users Only
How to target a logged user with FCM?

Related

Incorrect Event Users count on Answers

I currently have a Point of Sale application that allows for a user to login, make a purchase, and logout on an iPad. Each device supports multiple users, but I am noticing incorrect counts for "Event users". I am tracking logins, signups, and setting the Crashlytics userIdentifier property. What else do I need to do make sure Answers is properly tracking this information?
For example, I have had 30 users login to my application and go through the purchase flow, but Answers states that there have only been "2 Event Users".
Mike from Fabric here. An event user in this case would be connected to the device that is sending the event, not the user logged into the app which is likely the source of the disconnect.

How do I detect when a user has given permission to access the media library? (iOS 10) [duplicate]

This question already has answers here:
Detect permission of media library ios
(3 answers)
Closed 6 years ago.
In iOS 10, if an app accesses the music library, an Alert will be presented asking if the user gives permission for this access. This Alert is not part of the App. Is there some notification mechanism so that the App can be informed (a) that the Alert has been presented and (b) when the user has responded one way or the other?
The only work-around I have found is to relaunch the App after giving permission - not a very satisfactory way to deal with this.
Before accessing, request authorization yourself. See MPMediaLibrary.requestAuthorization(). It has a callback with the resulting status. You can also check the authorizationStatus() directly.

Real-time Push notifications with Firebase

I recently signed up to use Firebase and I can't seem to figure out how to push notifications to specific users.
For my use, I guess you can think of it like Facebook. Whenever a user does something, say posts an interesting article for their friends to read, I want all of the user's friends to be notified of that event. So, using Firebase, how would one make it possible to notify only their friends and not everyone? My database stores the conenctions.
Perhaps there is a way to have each user be a node in the Firebase database and each time a notification is sent, The user will constantly check his node, and if something appears, pulls it and then delete it.
The examples on Firebase seems to be sort of basic. I wish there was a user-specific push notification example.
Now Firebase supports Push Notification. Google rebranded GCM to Firebase Cloud Messaging and it now offers this cross platform service. Firebase also offers notifications.
These are the differences between these two services:
Firebase Cloud Messaging provides a complete set of messaging capabilities through its client SDKs and HTTP and XMPP server protocols. For deployments with more complex messaging requirements, FCM is the right choice.
Firebase Notifications is a lightweight, serverless messaging solution built on Firebase Cloud Messaging. With a user-friendly graphical console and reduced coding requirements, Firebase Notifications lets users easily send messages to reengage and retain users, foster app growth, and support marketing campaigns.
If you want a more detailed comparison. Read this.
There's a good explanation of how you can send notifications to specific users here:
How to send an alert message to a special online user with firebase
Basically you need to have each user observe a unique path, and then write data updates to the appropriate path.

How to send invitation to facebook friend from my application

Hi I am working on Rails application. My application is currently in 'invitation only' mode. What I want to do is once user signed up to my application then user should be able to invite his Facebook friends to my application. So what is the best way to do it? I want to do similar like pinterest does. pinterest is also in invitation only mode. But still it allows my facebook friend to whom I have sent an invite to sign up directly. So how I can implement it in my application? Any guidance will be helpful..
Use the requests dialog:
http://developers.facebook.com/docs/reference/dialogs/requests/
Store the list of user id's you get back (which you need to do anyhow
to delete the request programmatically when the come to your app)
When a user tries to login to your app, ensure that they're on your
list of id's you stored earlier.
Delete their app request
See http://developers.facebook.com/docs/reference/dialogs
Deleting Requests When a user is directed to your application, by
clicking a Request from the application, the games dashboard, or from
a Request notification, you must delete the request after it has been
accepted. Requests are not automatically deleted once they have been
clicked, thus it is the developer’s responsibility to clear them once
they have been consumed.

What are the dangers of tying one Facebook UID to multiple application accounts / tokens?

I'm getting started with a mix of Facebook Registration and Facebook Connect and wondering if there's a problem with my existing users foo#bar.com and bar#foo.com both connecting their accounts on my site to the same Facebook UID.
I can guess that if foo#bar.com connects to Facebook through my application, then bar#foo.com might have to re-authenticate because my application would use a different token for the same Facebook UID the second time. Would Facebook somehow reject the use of multiple tokens from my application?
To be clear - I know I can control whether or not the uniqueness is a problem in my database, I'm mostly trying to anticipate how Facebook will treat multiple different requests from the same application and if there might be any problems in how the application behaves.
Your question is so fogy. What you actually want to do? When you want to connect with facebook, it means you allow users to login in your system with their facebook accounts. So authentication will be done at facebook end. I am unable to understand your double ID phenomenon. What do you mean by two different ID's?