Please forgive me if this question is overlooking an incredibly basic GameSparks concept. I'm new to the platform and loving its capabilities so far, but have been stumped by this.
I've followed the examples established with the Cocos2d-x SDK and they have been very useful in establishing device registration and simple connection to GameSparks. However, I'm trying to implement Facebook Login as well. The Login works, and my plan was to have the successful login trigger the GameSparks authentication with the new token (GameSparks automatically checks for a FaceBook token on startup, but I wanted to have a FB login trigger it, as well).
I'm noticing that many of the request functions for GS require the passing in of a gsInstance argument. This makes sense, as the code needs to know which GS connection to pass the arguments through. However, I've looked over the API reference and cannot find a way to reference the active gsInstance, which looks like is initialized on startup in the AppDelegate header as it is in the example project.
My strategy was going to be creating an extern variable to reference the gsInstance, and pass that in with any functions that require it, but I wanted to make sure this doesn't create some kind of security risk. I also wanted to make sure that I'm not overlooking some simple getter function for the gsInstance.
Thank you!
Best Answer
C
Customer Support
said
over 6 years ago
Hi Matthew,
I can think of 2 ways to get around this problem. One of which being you create a new gsInstance pointing to the gsInstance in the AppDelegate header. You could wrap this up in a Singleton, or pass it throughout your application downstream (this is preferred for reasons I'll discuss later).
Another method would be to get the current instance of the AppDelegate whenever you need to by turning it into a Singleton. For more information on this design pattern please look here. There is also a sample implementation of this method in Cocos2dx here.
We're looking into this for you and will update you shortly,
-Pádraig
M
Matthew LeHew
said
over 6 years ago
Great, thanks so much! I've never dealt with an object instantiated through a private struct in the AppDelegate before, so I'm not sure as to which coding conventions are appropriate to deal with it.
Customer Support
said
over 6 years ago
Answer
Hi Matthew,
I can think of 2 ways to get around this problem. One of which being you create a new gsInstance pointing to the gsInstance in the AppDelegate header. You could wrap this up in a Singleton, or pass it throughout your application downstream (this is preferred for reasons I'll discuss later).
Another method would be to get the current instance of the AppDelegate whenever you need to by turning it into a Singleton. For more information on this design pattern please look here. There is also a sample implementation of this method in Cocos2dx here.
Matthew LeHew
Please forgive me if this question is overlooking an incredibly basic GameSparks concept. I'm new to the platform and loving its capabilities so far, but have been stumped by this.
I've followed the examples established with the Cocos2d-x SDK and they have been very useful in establishing device registration and simple connection to GameSparks. However, I'm trying to implement Facebook Login as well. The Login works, and my plan was to have the successful login trigger the GameSparks authentication with the new token (GameSparks automatically checks for a FaceBook token on startup, but I wanted to have a FB login trigger it, as well).
I'm noticing that many of the request functions for GS require the passing in of a gsInstance argument. This makes sense, as the code needs to know which GS connection to pass the arguments through. However, I've looked over the API reference and cannot find a way to reference the active gsInstance, which looks like is initialized on startup in the AppDelegate header as it is in the example project.
My strategy was going to be creating an extern variable to reference the gsInstance, and pass that in with any functions that require it, but I wanted to make sure this doesn't create some kind of security risk. I also wanted to make sure that I'm not overlooking some simple getter function for the gsInstance.
Thank you!
Hi Matthew,
I can think of 2 ways to get around this problem. One of which being you create a new gsInstance pointing to the gsInstance in the AppDelegate header. You could wrap this up in a Singleton, or pass it throughout your application downstream (this is preferred for reasons I'll discuss later).
Another method would be to get the current instance of the AppDelegate whenever you need to by turning it into a Singleton. For more information on this design pattern please look here. There is also a sample implementation of this method in Cocos2dx here.
Bear in mind that there is a lot of opinions on the prevailing use of Singelton's in games.
The Cocos2dx examples are being updated shortly so we will have more thorough documentation available for you soon.
I hope I was able to help with your issue, if not please let me know and I will continue investigating your issue.
-Pádraig
- Oldest First
- Popular
- Newest First
Sorted by Oldest FirstCustomer Support
Hi Matthew,
We're looking into this for you and will update you shortly,
-Pádraig
Matthew LeHew
Great, thanks so much! I've never dealt with an object instantiated through a private struct in the AppDelegate before, so I'm not sure as to which coding conventions are appropriate to deal with it.
Customer Support
Hi Matthew,
I can think of 2 ways to get around this problem. One of which being you create a new gsInstance pointing to the gsInstance in the AppDelegate header. You could wrap this up in a Singleton, or pass it throughout your application downstream (this is preferred for reasons I'll discuss later).
Another method would be to get the current instance of the AppDelegate whenever you need to by turning it into a Singleton. For more information on this design pattern please look here. There is also a sample implementation of this method in Cocos2dx here.
Bear in mind that there is a lot of opinions on the prevailing use of Singelton's in games.
The Cocos2dx examples are being updated shortly so we will have more thorough documentation available for you soon.
I hope I was able to help with your issue, if not please let me know and I will continue investigating your issue.
-Pádraig
Customer Support
Did this help you sort out your problem?
Sean
Matthew LeHew
Hi! This did, thank you very much!
-
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