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);
		}
Ejemplo n.º 2
0
        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)
        {

		}
Ejemplo n.º 5
0
 protected override void _removeUserProfile(UserProfile userProfile)
 {
     soomlaProfile_RemoveUserProfile(userProfile.toJSONObject().ToString());
 }
Ejemplo n.º 6
0
		protected virtual void _removeUserProfile(UserProfile userProfile) {
			#if UNITY_EDITOR
			string key = keyUserProfile(userProfile.Provider);
			PlayerPrefs.DeleteKey(key);
			#endif
		}
Ejemplo n.º 7
0
		/// <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);
		}
Ejemplo n.º 8
0
			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)
		{

		}
Ejemplo n.º 12
0
 protected virtual void _pushEventLoginFinished(UserProfile userProfileJson, string payload)
 {
 }
Ejemplo n.º 13
0
		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;
		}
Ejemplo n.º 14
0
 /// <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);
 }
Ejemplo n.º 15
0
 /// <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);
 }
Ejemplo n.º 16
0
		/// <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));
		}
Ejemplo n.º 17
0
		/// <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)));
		}
Ejemplo n.º 18
0
		protected override void _storeUserProfile(UserProfile userProfile, bool notify) {
			soomlaProfile_SetStoredUserProfile(userProfile.toJSONObject().ToString(), notify);
		}
Ejemplo n.º 19
0
		/// <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);
		}
Ejemplo n.º 20
0
		protected override void _removeUserProfile(UserProfile userProfile) {
			soomlaProfile_RemoveUserProfile(userProfile.toJSONObject().ToString());
		}
Ejemplo n.º 21
0
		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);
 }
Ejemplo n.º 23
0
		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;
		}
Ejemplo n.º 24
0
 protected override void _storeUserProfile(UserProfile userProfile, bool notify)
 {
     soomlaProfile_SetStoredUserProfile(userProfile.toJSONObject().ToString(), notify);
 }