iOS SDK FacebookConnectRequest and DeviceAuthenticationRequest
J
Jo Huang
started a topic
about 7 years ago
Hi,
My game needs to let player login first by DeviceAuthenticationRequest. Then optional link to Facebook account.
1. I currently send DeviceAuthenticationRequest with a fixed device ID to Authenticate every time the SDK is ready (available).
Do I need to do it every time or only first time right after user installed the app?
2. If I got the Facebook access token from FB SDK, and then send it via FacebookConnectRequest,
what should I do when user reopens the app or the network reconnects? Should I send DeviceAuthenticationRequest again? or FacebookConnectRequest? Or GS SDK does all for me?
3. What if Facebook token expired?
Just a lit bit confused about the whole process.
Thanks,
Jo
Best Answer
C
Customer Support
said
about 7 years ago
Hey Jo,
In your case i assume that there may be users who do not want to connect to FB, right?
So, in this case, i would suggest always checking for a FB connection when GS becomes available (i.e. in the GS.Available delegate). If none exists, then try a new connection. If it the connection fails then login with the deviceauthentication (you should set this up to always fails the first time a user logs in, so they always get a fresh GameSparks profile upon first using the app). Then they have an option to connect via facebook which preforms the FacebookConnectRequest and adds the FB token to their GS profile. Then, when the user returns to app, the following happens....
GS connects
FB connects
when FB becomes available preform the FacebookConnectRequest with the current token
User is now logged into GS via FB
As for the FB auth token, it is somewhat mysterious as to how long they last. But each time you login to FB on the client SDK it will generate a new token if the previous one has expired, so always use the one the SDK provides and dont store the token locally. It is only with development testing that you have to physically go and get a short-lived token. During a deployed build the SDK gets the token itself, and you'll be okay.
Hope that helps.
Sean
1 Comment
Customer Support
said
about 7 years ago
Answer
Hey Jo,
In your case i assume that there may be users who do not want to connect to FB, right?
So, in this case, i would suggest always checking for a FB connection when GS becomes available (i.e. in the GS.Available delegate). If none exists, then try a new connection. If it the connection fails then login with the deviceauthentication (you should set this up to always fails the first time a user logs in, so they always get a fresh GameSparks profile upon first using the app). Then they have an option to connect via facebook which preforms the FacebookConnectRequest and adds the FB token to their GS profile. Then, when the user returns to app, the following happens....
GS connects
FB connects
when FB becomes available preform the FacebookConnectRequest with the current token
User is now logged into GS via FB
As for the FB auth token, it is somewhat mysterious as to how long they last. But each time you login to FB on the client SDK it will generate a new token if the previous one has expired, so always use the one the SDK provides and dont store the token locally. It is only with development testing that you have to physically go and get a short-lived token. During a deployed build the SDK gets the token itself, and you'll be okay.
Jo Huang
Hi,
My game needs to let player login first by DeviceAuthenticationRequest. Then optional link to Facebook account.
1. I currently send DeviceAuthenticationRequest with a fixed device ID to Authenticate every time the SDK is ready (available).
Do I need to do it every time or only first time right after user installed the app?
2. If I got the Facebook access token from FB SDK, and then send it via FacebookConnectRequest,
what should I do when user reopens the app or the network reconnects? Should I send DeviceAuthenticationRequest again? or FacebookConnectRequest? Or GS SDK does all for me?
3. What if Facebook token expired?
Just a lit bit confused about the whole process.
Thanks,
Jo
In your case i assume that there may be users who do not want to connect to FB, right?
So, in this case, i would suggest always checking for a FB connection when GS becomes available (i.e. in the GS.Available delegate).
If none exists, then try a new connection.
If it the connection fails then login with the deviceauthentication (you should set this up to always fails the first time a user logs in, so they always get a fresh GameSparks profile upon first using the app).
Then they have an option to connect via facebook which preforms the FacebookConnectRequest and adds the FB token to their GS profile.
Then, when the user returns to app, the following happens....
As for the FB auth token, it is somewhat mysterious as to how long they last. But each time you login to FB on the client SDK it will generate a new token if the previous one has expired, so always use the one the SDK provides and dont store the token locally. It is only with development testing that you have to physically go and get a short-lived token. During a deployed build the SDK gets the token itself, and you'll be okay.
Hope that helps.
Sean
Customer Support
In your case i assume that there may be users who do not want to connect to FB, right?
So, in this case, i would suggest always checking for a FB connection when GS becomes available (i.e. in the GS.Available delegate).
If none exists, then try a new connection.
If it the connection fails then login with the deviceauthentication (you should set this up to always fails the first time a user logs in, so they always get a fresh GameSparks profile upon first using the app).
Then they have an option to connect via facebook which preforms the FacebookConnectRequest and adds the FB token to their GS profile.
Then, when the user returns to app, the following happens....
As for the FB auth token, it is somewhat mysterious as to how long they last. But each time you login to FB on the client SDK it will generate a new token if the previous one has expired, so always use the one the SDK provides and dont store the token locally. It is only with development testing that you have to physically go and get a short-lived token. During a deployed build the SDK gets the token itself, and you'll be okay.
Hope that helps.
Sean
-
Documentation Notes
-
Design issues with user events
-
Using NoSQL
-
Runtime Collections vs Metadata Collections
-
Anonymous authentication from browser app
-
Modules
-
Movement With Unity
-
Problem with url parameters for downloadables
-
Querying NoSql GameSparks database
-
Challenge accesType
See all 2487 topics