/// <summary> /// Method used for communication from iOS/Android -> Unity for passing an environment mode /// /// This method is called by native iOS/Android calls. /// </summary> /// <param name="environment">Environment to use</param> public void SetEnvironment(string environment) { //token between dev and production are assigned differently //token stored wont work when passed to WebView will show "No tournament found" if (RewardMobEndpoints.CurrentModeToString() != environment) { RewardMob.instance.Token = null; } switch (environment) { case ("dev"): RewardMobEndpoints.CurrentMode = RewardMobEndpoints.SDKMode.DEV; break; case ("prod"): default: RewardMobEndpoints.CurrentMode = RewardMobEndpoints.SDKMode.PROD; break; } }
/// <summary> /// Register /// </summary> /// <param name="message"></param> private static void RegisterWebviewSuccessCallbacks(string message) { //check to see if we're loading a URL from the callback if (message.StartsWith("url=")) { // Strip url= from string, leaving just the URL. string url = message.Substring(4); // Perform iOS Specific check. #if UNITY_IOS if (url.Contains("oauth/authorize") || url.Contains("auth/logout")) { // Logging in or out. // If iOS, call native code to load in SafariViewController. _OpenSafari(url); return; } #endif if (url.Contains("oauth/authorize")) { RewardMob.instance.isLoggingIn = true; } //Load in default browser if not IOS Application.OpenURL(url); return; } //handle different callback cases switch (message) { //bring user through authentication flow case ("authenticateUser"): Application.OpenURL(RewardMobEndpoints.GetAuthenticationURL()); break; //log the user out case ("logoutUser"): #if UNITY_IOS // If iOS, hit the Logout page in SafariViewController. _LogoutUser(RewardMobEndpoints.CurrentModeToString()); #endif RewardMob.instance.ClearPersistentData(); SampleWebView.webViewObject.SetVisibility(false); RewardMob.instance.OnClosedWebView(); RewardMob.instance.TotalRewardCount = 0; break; //hide the webview case ("hideWebView"): SampleWebView.webViewObject.SetVisibility(false); RewardMob.instance.OnClosedWebView(); break; //let client know that the page is done loading case ("pageDoneLoading"): RewardMob.instance.ToggleLoadingScreen(false); webViewObject.SetVisibility(true); break; default: break; } }