protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); Logger.Info(Tag, "onActivityResult, requestCode = " + requestCode + ", resultCode = " + resultCode); try { // Handle HMS SDK authentication sign in callback results if (requestCode == HmsProxyImpl.REQUEST_SIGN_IN_LOGIN) { // login success, get user message by getSignedInAccountFromIntent Task authHuaweiIdTask = HuaweiIdAuthManager.ParseAuthResultFromIntent(data); if (authHuaweiIdTask.IsSuccessful) { AuthHuaweiId huaweiAccount = (AuthHuaweiId)authHuaweiIdTask.Result; Logger.Info(Tag, "onActivityResult, signIn success " + huaweiAccount.DisplayName); HmsProxyImpl.Instance.DealSignInResult(huaweiAccount); InitDrive(); } else { // login failed Logger.Info(Tag, "onActivityResult, signIn failed: " + ((ApiException)authHuaweiIdTask.Exception).StatusCode); Toast.MakeText(ApplicationContext, "onActivityResult, signIn failed.", ToastLength.Long).Show(); } } } catch (Exception e) { Logger.Info(Tag, "onActivityResult, catch Exception"); } }
private void InitAutoRecorderController() { HiHealthOptions hiHealthOptions = HiHealthOptions.HiHealthOptionsBulider().Build(); AuthHuaweiId signInHuaweiId = HuaweiIdAuthManager.GetExtendedAuthResult(hiHealthOptions); MyAutoRecorderController = HuaweiHiHealth.GetAutoRecorderController(this, signInHuaweiId); }
//Initiate BleController private void InitBLEController() { if (MyBleController == null) { HiHealthOptions hiHealthOptions = HiHealthOptions.HiHealthOptionsBulider().Build(); AuthHuaweiId signInHuaweiId = HuaweiIdAuthManager.GetExtendedAuthResult(hiHealthOptions); MyBleController = HuaweiHiHealth.GetBleController(this, signInHuaweiId); } }
private void InitSettingController() { // create HiHealth Options, donnot add any datatype here. HiHealthOptions hiHealthOptions = HiHealthOptions.HiHealthOptionsBulider().Build(); // get AuthHuaweiId by HiHealth Options. AuthHuaweiId signInHuaweiId = HuaweiIdAuthManager.GetExtendedAuthResult(hiHealthOptions); MySettingController = HuaweiHiHealth.GetSettingController(this, signInHuaweiId); }
private void InitService() { Log.Info(TAG, "HiHealthKitClient connect to service"); // Initialize SettingController HiHealthOptions fitnessOptions = HiHealthOptions.HiHealthOptionsBulider().Build(); AuthHuaweiId signInHuaweiId = HuaweiIdAuthManager.GetExtendedAuthResult(fitnessOptions); MySettingController = HuaweiHiHealth.GetSettingController(this, signInHuaweiId); }
// Check the connectivity private void CheckConnect() { if (MyActivityRecordsController == null) { HiHealthOptions hiHealthOptions = HiHealthOptions.HiHealthOptionsBulider().Build(); AuthHuaweiId signInHuaweiId = HuaweiIdAuthManager.GetExtendedAuthResult(hiHealthOptions); MyActivityRecordsController = HuaweiHiHealth.GetActivityRecordsController(this, signInHuaweiId); } }
protected override void OnActivityResult(int requestCode, Android.App.Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); HiHealthOptions hiHealthOptions = HiHealthOptions.HiHealthOptionsBulider().Build(); AuthHuaweiId signInHuaweiId = HuaweiIdAuthManager.GetExtendedAuthResult(hiHealthOptions); MyAutoRecorderController = HuaweiHiHealth.GetAutoRecorderController(this, signInHuaweiId); }
public static IJosAppsClient GetJosAppsClient(AuthHuaweiId authHuaweiId) { var josAppsClient = sJavaClass.CallStatic <AndroidJavaObject>( "getJosAppsClient", AndroidContext.ActivityContext, authHuaweiId.JavaObject ); return(new JosAppsClientWrapper(josAppsClient)); }
private void SignedIn(AuthHuaweiId authHuaweiId) { string username = string.Format(authHuaweiId.DisplayName); PlayerPrefs.SetString("username", username); Debug.Log("[HMS]: SignedIn"); SceneManager.LoadScene("Home"); }
private void SignedIn(AuthHuaweiId authHuaweiId) { Debug.Log("[HMS]: SignedIn"); iapManager = GetComponent <IapManager>(); iapManager.OnCheckIapAvailabilitySuccess = LoadStore; iapManager.OnCheckIapAvailabilityFailure = (error) => { Debug.Log($"[HMSPlugin]: IAP check failed. {error.Message}"); }; iapManager.CheckIapAvailability(); }
/// <summary> /// Process certification results /// </summary> /// <param name="huaweiAccount">Huawei account</param> public void DealSignInResult(AuthHuaweiId huaweiAccount) { string tempAt = huaweiAccount.AccessToken; if (String.IsNullOrEmpty(tempAt)) { Log.Logger.Error(Tag, "dealSignInResult get accessToken is null."); return; } Log.Logger.Info(Tag, "dealSignInResult signInBackend get new AT successfully"); SaveAccountInfo(huaweiAccount); }
private void InitDataController() { // Obtain and set the read & write permissions for DtContinuousStepsDelta and DtInstantaneousHeight. // Use the obtained permissions to obtain the data controller object. HiHealthOptions hiHealthOptions = HiHealthOptions.HiHealthOptionsBulider() .AddDataType(DataType.DtContinuousStepsDelta, HiHealthOptions.AccessRead) .AddDataType(DataType.DtContinuousStepsDelta, HiHealthOptions.AccessWrite) .AddDataType(DataType.DtInstantaneousHeight, HiHealthOptions.AccessRead) .AddDataType(DataType.DtInstantaneousHeight, HiHealthOptions.AccessWrite) .Build(); AuthHuaweiId signInHuaweiId = HuaweiIdAuthManager.GetExtendedAuthResult(hiHealthOptions); MyDataController = HuaweiHiHealth.GetDataController(this, signInHuaweiId); }
/// <summary> /// Save account info /// </summary> private void SaveAccountInfo(AuthHuaweiId signInHuaweiId) { if (signInHuaweiId == null) { return; } unionId = signInHuaweiId.UnionId; deviceId = signInHuaweiId.OpenId; displayName = signInHuaweiId.DisplayName; status = signInHuaweiId.Status; gender = signInHuaweiId.Gender; grantedScopes = signInHuaweiId.AuthorizedScopes; serviceCountryCode = signInHuaweiId.ServiceCountryCode; accessToken = signInHuaweiId.AccessToken; }
public async void StopRecordByType() { Logger("StopRecordByType"); if (MyAutoRecorderController == null) { HiHealthOptions hiHealthOptions = HiHealthOptions.HiHealthOptionsBulider().Build(); AuthHuaweiId signInHuaweiId = HuaweiIdAuthManager.GetExtendedAuthResult(hiHealthOptions); MyAutoRecorderController = HuaweiHiHealth.GetAutoRecorderController(this, signInHuaweiId); } Task StopTask = MyAutoRecorderController.StopRecordAsync(Huawei.Hms.Hihealth.Data.DataType.DtContinuousStepsTotal, new MySamplePointListener()); try { await StopTask; if (StopTask.IsCompleted) { if (StopTask.Exception == null) { Logger("StopRecordByType Successful"); Logger(Split); } else { Logger("StopRecordByType Failed: " + StopTask.Exception); Logger(Split); } } } catch (System.Exception ex) { Logger("StopRecordByType Failed: " + ex.Message); Logger(Split); } if (Count > 0) { StopService(intent); this.UnregisterReceiver(Receiver); Count--; } }
protected override void OnActivityResult(int requestCode, [GeneratedEnum] Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == 8888) { var authHuaweiIdTask = HuaweiIdAuthManager.ParseAuthResultFromIntent(data); if (authHuaweiIdTask.IsSuccessful) { //The sign-in is successful, and the user's HUAWEI ID information and ID token are obtained. AuthHuaweiId huaweiAccount = authHuaweiIdTask.GetResult <AuthHuaweiId>(); Log.Info(TAG, "idToken:" + huaweiAccount.IdToken); } else { //The sign-in failed. Log.Error(TAG, "sign in failed : " + ((ApiException)authHuaweiIdTask.Exception).StatusCode); } } }
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data) { base.OnActivityResult(requestCode, resultCode, data); if (requestCode == Constant.RequestSignInLogin) { //login success //get user message by ParseAuthResultFromIntent Task authHuaweiIdTask = HuaweiIdAuthManager.ParseAuthResultFromIntent(data); if (authHuaweiIdTask.IsSuccessful) { AuthHuaweiId huaweiAccount = (AuthHuaweiId)authHuaweiIdTask.Result; Log.InfoFunc(TAG, huaweiAccount.DisplayName + " signIn success "); Log.InfoFunc(TAG, "AccessToken: " + huaweiAccount.AccessToken); ValidateIdToken(huaweiAccount.IdToken); } else { Log.InfoFunc(TAG, "signIn failed: " + (authHuaweiIdTask.Exception).ToString()); } } if (requestCode == Constant.RequestSignInLoginCode) { //login success Task authHuaweiIdTask = HuaweiIdAuthManager.ParseAuthResultFromIntent(data); if (authHuaweiIdTask.IsSuccessful) { AuthHuaweiId huaweiAccount = (AuthHuaweiId)authHuaweiIdTask.Result; Log.InfoFunc(TAG, "signIn get code success."); Log.InfoFunc(TAG, "ServerAuthCode: " + huaweiAccount.AuthorizationCode); /**** english doc:For security reasons, the operation of changing the code to an AT must be performed on your server. The code is only an example and cannot be run. ****/ /**********************************************************************************************/ } else { Log.InfoFunc(TAG, "signIn get code failed: " + (authHuaweiIdTask.Exception).ToString()); } } }
public void AuthenticateUser(Action <bool> callback = null) { if (!IsAuthenticated()) { _authService.StartSignIn(authId => { Debug.Log(TAG + ": Signed In Succesfully!"); commonAuthUser = new CommonAuthUser { email = authId.Email, name = authId.DisplayName, id = authId.OpenId, photoUrl = authId.AvatarUriString }; PlayerPrefs.SetInt("autoLogin", 1); HuaweiId = authId; Debug.Log(TAG + ": HuaweiIdToken is " + HuaweiId.IdToken); //Load IJosAppClient for HMS HuaweiMobileServicesUtil.SetApplication(); IJosAppsClient josAppsClient = JosApps.GetJosAppsClient(HuaweiId); josAppsClient.Init(); _rankingClient = Games.GetRankingsClient(HuaweiId); _achievementClient = Games.GetAchievementsClient(HuaweiId); callback?.Invoke(true); }, (error) => { commonAuthUser = null; callback?.Invoke(false); }); } }
private void Init() { HiHealthOptions hiHealthOptions = HiHealthOptions.HiHealthOptionsBulider().Build(); AuthHuaweiId signInHuaweiId = HuaweiIdAuthManager.GetExtendedAuthResult(hiHealthOptions); MyActivityRecordsController = HuaweiHiHealth.GetActivityRecordsController(this, signInHuaweiId); MyDataController = HuaweiHiHealth.GetDataController(this, signInHuaweiId); LogInfoView = (TextView)FindViewById(Resource.Id.activity_records_controller_log_info); LogInfoView.MovementMethod = ScrollingMovementMethod.Instance; BeginActivity = (Button)FindViewById(Resource.Id.records_controller_begin_activity); EndActivity = (Button)FindViewById(Resource.Id.records_controller_end_activity); AddActivity = (Button)FindViewById(Resource.Id.records_controller_add_activity); GetActivity = (Button)FindViewById(Resource.Id.records_controller_get_activity); DeleteActivity = (Button)FindViewById(Resource.Id.records_controller_delete_activity); BeginActivity.Click += delegate { BeginActivityRecord(); }; EndActivity.Click += delegate { EndActivityRecord(); }; AddActivity.Click += delegate { AddActivityRecord(); }; GetActivity.Click += delegate { GetActivityRecord(); }; DeleteActivity.Click += delegate { DeleteActivityRecord(); }; }
public static IGameSummaryClient GetGameSummaryClient(AuthHuaweiId paramAuthHuaweiId) => sJavaClass.CallStaticAsWrapper <GameSummaryClientWrapper>("getGameSummaryClient", AndroidContext.ActivityContext, paramAuthHuaweiId);
public void OnLoginSuccess(AuthHuaweiId authHuaweiId) { loggedInUser.text = string.Format(LOGGED_IN, authHuaweiId.DisplayName); }
public static IPlayersClient GetPlayersClient(AuthHuaweiId authHuaweiId) => sJavaClass.CallStaticAsWrapper <PlayersClientWrapper>("getPlayersClient", AndroidContext.ActivityContext, authHuaweiId.JavaObject);
public Player(string json, AuthHuaweiId authHuaweiId) : base("com.huawei.hms.jos.games.player.Player", json.AsJavaString(), authHuaweiId.JavaObject) { }
public void OnLoginSuccess(AuthHuaweiId authHuaweiId) { Debug.Log(authHuaweiId); }
public static IAchievementsClient GetAchievementsClient(AuthHuaweiId authHuaweiId) => sJavaClass.CallStaticAsWrapper <AchievementClientWrapper>("getAchievementsClient", AndroidContext.ActivityContext, authHuaweiId.JavaObject);
public static IArchivesClient GetArchiveClient(AuthHuaweiId paramAuthHuaweiId) => GamesClass.CallStaticAsWrapper <ArchivesClientWrapper>("getArchiveClient", AndroidContext.ActivityContext, paramAuthHuaweiId);
public static IGamePlayerStatisticsClient GetGamePlayerStatsClient(AuthHuaweiId paramAuthHuaweiId) => GamesClass.CallStaticAsWrapper <GamePlayerStatisticsClientWrapper>("getGamePlayerStatsClient", AndroidContext.ActivityContext, paramAuthHuaweiId);
public static IRankingsClient GetRankingsClient(AuthHuaweiId authHuaweiId) => GamesClass.CallStaticAsWrapper <RankingsClientWrapper>("getRankingsClient", AndroidContext.ActivityContext, authHuaweiId);
private void OnAccountKitLoginSuccess(AuthHuaweiId authHuaweiId) { AGConnectAuthCredential credential = HwIdAuthProvider.CredentialWithToken(authHuaweiId.AccessToken); authServiceManager.SignIn(credential); }
public static IGamesClient GetGamesClient(AuthHuaweiId authHuaweiId) => GamesClass.CallStaticAsWrapper <GamesClientWrapper>("getGamesClient", AndroidContext.ActivityContext, authHuaweiId.JavaObject);
public void SavedGameAuth() { HuaweiId = accountManager.HuaweiId; }