50 lines
1.7 KiB
TypeScript
50 lines
1.7 KiB
TypeScript
const { ccclass, property } = cc._decorator;
|
|
|
|
@ccclass
|
|
export class URLSchemeHandler extends cc.Component {
|
|
|
|
//#region Custom
|
|
|
|
public static Init(): boolean {
|
|
try {
|
|
// bool isFirst = false;
|
|
// if (_instance == null) {
|
|
// _instance = Component.FindObjectOfType<URLSchemeHandler>();
|
|
// if (_instance == null) {
|
|
// _instance = new GameObject("URLSchemeOriginManager").AddComponent<URLSchemeHandler>();
|
|
// }
|
|
// isFirst = true;
|
|
// #if UNITY_EDITOR
|
|
// _instance.firstOpen = false;
|
|
// #endif
|
|
// }
|
|
// #if UNITY_EDITOR
|
|
// else
|
|
// {
|
|
// isFirst = _instance.firstOpen;
|
|
// }
|
|
// #endif
|
|
|
|
// #if UNITY_EDITOR || UNITY_ANDROID
|
|
// //Debug.LogWarning("URLSchemeHandler can not use in editor mode.");
|
|
// UtilsNativeActivity.Init();
|
|
// UtilsNativeActivity.SetCallbackOnNewIntent(_instance.callbackOnNewIntent);
|
|
// return isFirst;
|
|
|
|
// #elif UNITY_IPHONE || UNITY_IOS
|
|
|
|
// UtilsNativeActivity.Init();
|
|
// UtilsNativeActivity.SetCallbackOnNewIntent(_instance.callbackOnNewIntent);
|
|
|
|
// _setCallbackURLScheme(UtilsNativeActivity.HANDLER_OBJECT_NAME, UtilsNativeActivity.HANDLER_METHOD_NAME);
|
|
// return true;
|
|
// #endif
|
|
} catch (error: any) {
|
|
cc.error("URLSchemeHandler error : " + error.toString());
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
//#endregion
|
|
} |