Obtain InstanceID (GetInstanceIDAsync)
caution
[MSDK only] The GetInstanceID API mentioned in this section is deprecated starting from MSDKV5.16. Please use getInstanceIDAsync to obtain the InstanceID.
[Player Network SDK & MSDK] The Firebase channel obtains the Firebase InstanceID.
Firebase Instance ID provides a unique identifier for each installation of an app.The Instance ID will change in the following situations:
- The app calls
deleteInstanceIdAPI to erase Instance ID. - User uninstalls/reinstalls the app
- User deletes app data
Supported channel: Firebase
Supported platforms
- Unity
- Unreal Engine
Supports
Android, iOS platform.Supports
Android, iOS platform.Function Definition
- Unity
- Unreal Engine
string GetInstanceID(string channel);
static std::string GetInstanceID(const std::string &channel);
Input Parameters
- Unity
- Unreal Engine
| Parameters | Type | Description |
|---|---|---|
| channel | string | Channel definition |
| Parameters | Type | Description |
|---|---|---|
| channel | std::string | Channel definition |
Code Example
- Unity
- Unreal Engine
UnionAdapterAPI.GetReportService().GetInstanceID("Firebase");
GUA_NAMESPACE::GUAReportService::GetInstanceID("Firebase");
getInstanceIDAsync code example
- Unity
- Unreal Engine
// Set Extend callback
UnionAdapterAPI.GetExtendService().ExtendRetEvents += mLoginCallBack.OnExtendRetEvent;
// Call getInstanceIDAsync
UnionAdapterAPI.GetExtendService().Invoke ("Firebase", "getInstanceIDAsync", "");
// Get result in callback, the result is in extendRet.extraJson, JSON format as follows: {"instanceID":"xxxxxxx"}
public void OnExtendRetEvent (GUAExtendResult extendRet)
{
string methodTag = extendRet.extendMethodName;
mCurrentTestMgr.ShowLogInNewLine (methodTag + extendRet);
}
// Set Extend callback
GUA_NAMESPACE::GUAExtendService::SetExtendObserver(mGUAExtendCallBacks);
// Call getInstanceIDAsync
GUA_NAMESPACE::GetExtendService::Invoke("Firebase", "getInstanceIDAsync", "");
// Get result in callback, the result is in extendRet.extraJson, JSON format as follows: {"instanceID":"xxxxxxx"}
class MyExtendObserver : public GUA_NAMESPACE::GUAExtendObserver {
public:
void OnExtendNotify(const GUAExtendResult &extendRet) {
handleCallback(extendRet, extendRet.method_id);
};
};