protected override void _pushEventLoginFinished(UserProfile userProfile, bool autoLogin, string payload) { if (SoomlaProfile.IsProviderNativelyImplemented(userProfile.Provider)) return; AndroidJNI.PushLocalFrame(100); using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.ProfileEventHandler")) { ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "pushEventLoginFinished", userProfile.toJSONObject().print(), autoLogin, payload); } AndroidJNI.PopLocalFrame(IntPtr.Zero); }
private static UserProfile UserProfileFromFBJson(JSONObject fbJsonObject) { JSONObject soomlaJsonObject = new JSONObject (); soomlaJsonObject.AddField(PJSONConsts.UP_PROVIDER, Provider.FACEBOOK.ToString ()); soomlaJsonObject.AddField(PJSONConsts.UP_PROFILEID, fbJsonObject["id"].str); string name = fbJsonObject ["name"].str; soomlaJsonObject.AddField(PJSONConsts.UP_USERNAME, name); string email = fbJsonObject ["email"] != null ? fbJsonObject ["email"].str : null; if (email == null) { email = Regex.Replace(name, @"\s+", ".") + "@facebook.com"; } soomlaJsonObject.AddField(PJSONConsts.UP_EMAIL, email); soomlaJsonObject.AddField(PJSONConsts.UP_FIRSTNAME, fbJsonObject["first_name"].str); soomlaJsonObject.AddField(PJSONConsts.UP_LASTNAME, fbJsonObject["last_name"].str); soomlaJsonObject.AddField(PJSONConsts.UP_AVATAR, fbJsonObject["picture"]["data"]["url"].str); UserProfile userProfile = new UserProfile (soomlaJsonObject); return userProfile; }
public UserProfileUpdatedEvent(UserProfile userProfile, Object sender) : base(sender) { this.UserProfile = userProfile; }
public UserProfileUpdatedEvent(UserProfile userProfile) : this(userProfile, null) { }
protected override void _removeUserProfile(UserProfile userProfile) { soomlaProfile_RemoveUserProfile(userProfile.toJSONObject().ToString()); }
protected virtual void _removeUserProfile(UserProfile userProfile) { #if UNITY_EDITOR string key = keyUserProfile(userProfile.Provider); PlayerPrefs.DeleteKey(key); #endif }
/// <summary> /// Removes the given user profile in the relevant provider (contained internally in the UserProfile). /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="userProfile">User profile to store.</param> public static void RemoveUserProfile (UserProfile userProfile) { instance._removeUserProfile (userProfile); }
protected virtual void _pushEventLoginFinished(UserProfile userProfileJson, bool autoLogin, string payload){}
protected override void _removeUserProfile(UserProfile userProfile) { AndroidJNI.PushLocalFrame(100); using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.UnitySoomlaProfile")) { ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "removeUserProfile", userProfile.toJSONObject().ToString()); } AndroidJNI.PopLocalFrame(IntPtr.Zero); }
public LoginFinishedEvent (UserProfile userProfile, bool autoLogin, string payload, Object sender):base(sender, payload) { UserProfile = userProfile; AutoLogin = autoLogin; }
public LoginFinishedEvent (UserProfile userProfile, bool autoLogin, string payload):this(userProfile, autoLogin, payload,null) { }
protected virtual void _pushEventLoginFinished(UserProfile userProfileJson, string payload) { }
public Score(JSONObject jsonSC) { this.Leaderboard = new Leaderboard(jsonSC[PJSONConsts.UP_LEADERBOARD]); this.Player = new UserProfile(jsonSC[PJSONConsts.UP_USER_PROFILE]); this.Rank = (long)jsonSC[PJSONConsts.UP_SCORE_RANK].n; this.Value = (long)jsonSC[PJSONConsts.UP_SCORE_VALUE].n; }
/// <summary> /// Removes the given user profile in the relevant provider (contained internally in the UserProfile). /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="userProfile">User profile to store.</param> public static void RemoveUserProfile(UserProfile userProfile) { instance._removeUserProfile(userProfile); }
/// <summary> /// Stores the given user profile in the relevant provider (contained internally in the UserProfile). /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="userProfile">User profile to store.</param> /// <param name="notify">If set to <c>true</c>, notify.</param> public static void StoreUserProfile(UserProfile userProfile, bool notify = false) { instance._storeUserProfile(userProfile, notify); }
/// <summary> /// Handles an <c>onUserProfileUpdated</c> event /// </summary> /// <param name="message">Will contain a JSON representation of a <c>UserProfile</c></param> public void onUserProfileUpdated(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onUserProfileUpdated"); JSONObject eventJson = new JSONObject(message); UserProfile userProfile = new UserProfile (eventJson ["userProfile"]); ProfileEvents.OnUserProfileUpdated (userProfile); //ProfileEvents.OnUserProfileUpdated (new UserProfileUpdatedEvent(userProfile)); }
/// <summary> /// Handles an <c>onLoginFinished</c> event /// </summary> /// <param name="message">Will contain a JSON representation of a <c>UserProfile</c> and payload</param> public void onLoginFinished(String message) { SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onLoginFinished"); JSONObject eventJson = new JSONObject(message); UserProfile userProfile = new UserProfile (eventJson ["userProfile"]); bool autoLogin = eventJson["autoLogin"].b; JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str); //give a reward Reward reward = Reward.GetReward(ProfilePayload.GetRewardId(payloadJSON)); if (reward !=null) reward.Give(); ProfileEvents.OnLoginFinished(userProfile, autoLogin, ProfilePayload.GetUserPayload(payloadJSON)); //ProfileEvents.OnLoginFinished(new LoginFinishedEvent(userProfile, autoLogin, ProfilePayload.GetUserPayload(payloadJSON))); }
protected override void _storeUserProfile(UserProfile userProfile, bool notify) { soomlaProfile_SetStoredUserProfile(userProfile.toJSONObject().ToString(), notify); }
/// <summary> /// Stores the given user profile in the relevant provider (contained internally in the UserProfile). /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="userProfile">User profile to store.</param> /// <param name="notify">If set to <c>true</c>, notify.</param> public static void StoreUserProfile (UserProfile userProfile, bool notify = false) { instance._storeUserProfile (userProfile, notify); }
protected virtual void _storeUserProfile(UserProfile userProfile, bool notify) { #if UNITY_EDITOR string key = keyUserProfile(userProfile.Provider); string val = userProfile.toJSONObject().ToString(); SoomlaUtils.LogDebug(TAG, "key/val:" + key + "/" + val); PlayerPrefs.SetString(key, val); if (notify) { ProfileEvents.OnUserProfileUpdated(userProfile); } #endif }
protected override void _pushEventLoginFinished(UserProfile userProfile, bool autoLogin, string payload) { if (SoomlaProfile.IsProviderNativelyImplemented(userProfile.Provider)) return; soomlaProfile_PushEventLoginFinished(userProfile.toJSONObject().print(), autoLogin, payload); }
private static UserProfile UserProfileFromFBJson(JSONObject fbJsonObject, FBSocialProvider provider) { JSONObject soomlaJsonObject = new JSONObject (); soomlaJsonObject.AddField(PJSONConsts.UP_PROVIDER, Provider.FACEBOOK.ToString ()); soomlaJsonObject.AddField(PJSONConsts.UP_PROFILEID, fbJsonObject["id"].str); string name = fbJsonObject ["name"].str; soomlaJsonObject.AddField(PJSONConsts.UP_USERNAME, name); string email = fbJsonObject ["email"] != null ? fbJsonObject ["email"].str : null; if (email == null) { email = Regex.Replace(name, @"\s+", ".") + "@facebook.com"; } soomlaJsonObject.AddField(PJSONConsts.UP_EMAIL, email); soomlaJsonObject.AddField(PJSONConsts.UP_FIRSTNAME, fbJsonObject["first_name"].str); soomlaJsonObject.AddField(PJSONConsts.UP_LASTNAME, fbJsonObject["last_name"].str); soomlaJsonObject.AddField(PJSONConsts.UP_AVATAR, fbJsonObject["picture"]["data"]["url"].str); if (fbJsonObject["gender"] != null) { soomlaJsonObject.AddField(PJSONConsts.UP_GENDER, fbJsonObject["gender"].str); } if (fbJsonObject["languages"] != null && fbJsonObject["languages"].Count > 0 && fbJsonObject["languages"][0] != null && fbJsonObject["languages"][0]["name"] != null) { soomlaJsonObject.AddField(PJSONConsts.UP_LANGUAGE, fbJsonObject["languages"][0]["name"].str); } if (fbJsonObject["location"] != null && fbJsonObject["location"]["name"] != null) { soomlaJsonObject.AddField(PJSONConsts.UP_LOCATION, fbJsonObject["location"]["name"].str); } if (provider != null) { //let us to know if method called during own profile receiving Dictionary<String, JSONObject> extraDict = new Dictionary<String, JSONObject>(); extraDict.Add("access_token", JSONObject.StringObject(AccessToken.CurrentAccessToken.TokenString)); JSONObject permissionsObject = JSONObject.Create(JSONObject.Type.ARRAY); foreach (String permission in provider.permissions) { permissionsObject.Add(permission); } extraDict.Add("permissions", permissionsObject); extraDict.Add("expiration_date", new JSONObject((AccessToken.CurrentAccessToken.ExpirationTime - new DateTime(1970, 1, 1)).TotalSeconds)); soomlaJsonObject.AddField(PJSONConsts.UP_EXTRA, new JSONObject(extraDict)); } UserProfile userProfile = new UserProfile(soomlaJsonObject); return userProfile; }