Getting expo-token from logged in user - react-native

I am building my first multiuser react-native app with Expo and I am trying to set up notifications. In order to do that, I need to get the expo-token from a user. The way I logged in users is with AsyncStorage. How can I get the expo-token from a logged-in user so that I will send a user a notification once a different user makes an action?

Related

Get all dialogs in a QuickBlox application?

Every one hour, our server has to notify all the users who haven't read the messages.
Can we do that with QuickBlox? We have the credentials of all users stored. So, we can login with each user and get his dialogs and check if there are any unread messages but that's a very long process. We can't login with each user. Is there any way we can get list of dialogs from the application level?

send notification to a particular user with notification hub - Azure and GCM

I am a software developer in Xamarin - Android, I want to create notification messages. For this purpose I use Azure notification hub, combined with Google's service - Google Cloud Messaging (GCM).
My problem comes when I want to send notification to a particular user. I realized that I need to use the "TAGS" When I compose a new user to the system (Uniqe TAG)
Indeed, it works great, but when the user logged off his account, and then connect to another one (with another TAGS) - the TAGS of his old account are kept in a certain time, and he continues to receive personal messages from the previous account!!!!
Does anyone know what can be done about it?
thank you very much
This is actually an issue a lot of people/apps have on iOS and Android.
What you should do is:
Register your app at your Azure Notification Hub (ANH) on first start and reregister at every app start, to keep registration in sync
If a user logs in, update the registration with an additional tag for this user (e.g. "user:XY")
Sending notifications to that user tag will of course result in notifications on all devices the user is logged in on
If a user logs out, update the registration without the user tag (omit the user tag, so the registration doesn't have user tag anymore afterwards)
The registration will be updated immediately on ANH and sending notifications to the user (tag) will not result in notifications on that specific client
If the user can logout on your app without internet connection, you won't be able to update the registration of course and you will still have the problem of getting notifications for a logged out user. But as soon as another user logs in, the registration should get updated with the new user tag and everything should be fine again...
What you shouldn't do:
"Developers should never unregister the client app as a mechanism for logout or for switching between users..."

Basics of Facebook login

I'm having a hard time understanding how Facebook communicates with my server when a user logs in (after approving my facebook app). I've been looking through guides and other Stackoverflow questions for hours on end but can't seem to get the hang of it. The documentation on http://developers.facebook.com/ isn't to much help much either.
What I want to do is to have a Facebook login button on my page which opens a Facebook login window (using Facebook's Javascript SDK). When the user then logs in to Facebook and approves my app I want to get the user's data (name, email, age) and store it in my database. How do I get this data, SECURELY (server-side confirmation/authorization)?
Basically, in this order;
a user clicks log-in button on my site
a pop-up is shown where the user can log in & approve the app on Facebook
check if user has already logged in before by getting user's user_id
if it's the users first time logging in, the user's Facebook data (specifically: full name, picture, email adress, age) is gathered by me and stored in my database
After the user logs/approves the app in the Facebook pop-up, where is the user's data then sent?
After the user approves the app, the user's data is not sent anywhere. You need to make an API call to retrieve the data.
Facebook is an OAuth provider. You use Facebook Login so the user can give you permission to access her Facebook data (such as email, friend list, messages, news feed etc). You can also get permissions to take action on behalf of the user (such as uploading a photo, posting to news feed etc.) While starting the OAuth flow, you specify which permissions you will request from the user. These are called scopes.
The authorization flow that happens in the pop-up window is there for the user to give you permission to access the data that you request. This permission is represented as an access token which you have to use everytime you want to retreive user data, or attempt to do something on behalf of the user.
Once you have the access token, you can use the Facebook Graph API to get whatever data you want from Facebook. If you try to access some data that you did not get permission for, then the API method will return an access denied error.
I wanted to give some more links about scopes and access tokens from the Facebook Developers site but my reputation score is too low :)

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.

iOS Push Notifications to specific user in the same deviceToken

I am using Urban Airship to test push notification and it went well.
My problem is how do I specify which user to get the notification not just the device token.
I mean in some situations where one device has multiple users, so many users registered the same device token to server.
Or do I have to do the filter on the device (client side) itself?
There's no real way to do what you want unfortunately. In APNS there's only such thing as a device. You push a device and it shows a message / badge / sound on that device.
If your app can have multiple users associated with it then you'd need to work out from the push which user it relates to and handle it accordingly. How you do that would depend on your app but you could add in a custom key to the push which indicated the user it's for.
If your app only ever has one user logged in at once then I suggest that when you hand the push token to your server, the server first turns off push for the user that the token was originally registered for and subsequently turns push on for the new user.