protected override void _logout (Provider provider){
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.UnitySoomlaProfile")) {
				ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "logout", provider.ToString());
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
		}
		protected override void _updateStatus(Provider provider, string status, string payload){
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.UnitySoomlaProfile")) {
				ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "updateStatus", provider.ToString(), status, payload);
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
		}
		protected override void _pushEventLoginFailed(Provider provider, string message, bool autoLogin, string payload) {
			if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.ProfileEventHandler")) {
				ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "pushEventLoginFailed", provider.ToString(), message, autoLogin, payload);
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
		}
 protected override void _getFeed(Provider provider, bool fromStart, string payload)
 {
     AndroidJNI.PushLocalFrame(100);
     using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.UnitySoomlaProfile")) {
         ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "getFeed", provider.ToString(), fromStart, payload);
     }
     AndroidJNI.PopLocalFrame(IntPtr.Zero);
 }
		protected override void _pushEventLogoutFinished(Provider provider) {
			if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.ProfileEventHandler")) {
				ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "pushEventLogoutFinished", provider.ToString());
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
		}
		protected override void _login(Provider provider, string payload){
			AndroidJNI.PushLocalFrame(100);
			using (AndroidJavaClass unityActivityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
				using(AndroidJavaObject unityActivity = unityActivityClass.GetStatic<AndroidJavaObject>("currentActivity")) {
					using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.UnitySoomlaProfile")) {
						ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "login", unityActivity, provider.ToString(), payload);
					}
				}
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
		}
        protected override void _pushEventGetContactsFinished(Provider provider, SocialPageData<UserProfile> contactsPage, string payload)
        {
            if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
            List<JSONObject> profiles = new List<JSONObject>();
            foreach (var profile in contactsPage.PageData) {
                profiles.Add(profile.toJSONObject());
            }
            JSONObject contacts = new JSONObject(profiles.ToArray());

            soomlaProfile_PushEventGetContactsFinished(provider.ToString(), contacts.ToString(), payload, contactsPage.HasMore);
        }
		protected override bool _isLoggedIn(Provider provider) {
			bool loggedIn;
			AndroidJNI.PushLocalFrame(100);
			using (AndroidJavaClass unityActivityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
				using(AndroidJavaObject unityActivity = unityActivityClass.GetStatic<AndroidJavaObject>("currentActivity")) {
					using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.UnitySoomlaProfile")) {
						loggedIn = ProfileJNIHandler.CallStatic<bool>(jniSoomlaProfile, "isLoggedIn", unityActivity, provider.ToString());
					}
				}
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
			return loggedIn;
		}
        protected override UserProfile _getStoredUserProfile(Provider provider)
        {
            IntPtr p = IntPtr.Zero;
            int err = soomlaProfile_GetStoredUserProfile(provider.ToString(), out p);
            IOS_ProfileErrorCodes.CheckAndThrowException(err);

            string json = Marshal.PtrToStringAnsi(p);
            Marshal.FreeHGlobal(p);
            SoomlaUtils.LogDebug(TAG, "Got json: " + json);

            JSONObject obj = new JSONObject(json);
            return new UserProfile(obj);
        }
 protected override string _getAccessToken(Provider provider)
 {
     string accessToken;
     AndroidJNI.PushLocalFrame(100);
     using (AndroidJavaClass unityActivityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
         using(AndroidJavaObject unityActivity = unityActivityClass.GetStatic<AndroidJavaObject>("currentActivity")) {
             using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.UnitySoomlaProfile")) {
                 accessToken = ProfileJNIHandler.CallStatic<string>(jniSoomlaProfile, "getAccessToken", unityActivity, provider.ToString());
             }
         }
     }
     AndroidJNI.PopLocalFrame(IntPtr.Zero);
     return accessToken;
 }
        protected override void _pushEventGetContactsFinished(Provider provider, SocialPageData<UserProfile> contactsPage, string payload)
        {
            if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
            List<JSONObject> profiles = new List<JSONObject>();
            foreach (var profile in contactsPage.PageData) {
                profiles.Add(profile.toJSONObject());
            }
            JSONObject contacts = new JSONObject(profiles.ToArray());

            AndroidJNI.PushLocalFrame(100);
            using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.ProfileEventHandler")) {
                ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "pushEventGetContactsFinished",
                                                 provider.ToString(), contacts.ToString(), payload, contactsPage.HasMore);
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
        }
Example #12
0
        protected override UserProfile _getStoredUserProfile(Provider provider)
        {
            IntPtr p   = IntPtr.Zero;
            int    err = soomlaProfile_GetStoredUserProfile(provider.ToString(), out p);

            IOS_ProfileErrorCodes.CheckAndThrowException(err);

            string json = Marshal.PtrToStringAnsi(p);

            Marshal.FreeHGlobal(p);
            SoomlaUtils.LogDebug(TAG, "Got json: " + json);

            JSONObject obj = new JSONObject(json);

            return(new UserProfile(obj));
        }
        protected override void _pushEventGetFeedFinished(Provider provider, SocialPageData <String> feedPage, string payload)
        {
            if (SoomlaProfile.IsProviderNativelyImplemented(provider))
            {
                return;
            }
            List <JSONObject> feeds = new List <JSONObject>();

            foreach (var feed in feedPage.PageData)
            {
                feeds.Add(JSONObject.StringObject(feed));
            }
            JSONObject jsonFeeds = new JSONObject(feeds.ToArray());

            soomlaProfile_PushEventGetFeedFinished(provider.ToString(), jsonFeeds.ToString(), payload, feedPage.HasMore);
        }
        protected override void _pushEventInviteFinished(Provider provider, string requestId, List <string> invitedIds, string payload)
        {
            if (SoomlaProfile.IsProviderNativelyImplemented(provider))
            {
                return;
            }
            List <JSONObject> invited = new List <JSONObject>();

            foreach (var id in invitedIds)
            {
                invited.Add(JSONObject.StringObject(id));
            }
            JSONObject jsonInvited = new JSONObject(invited.ToArray());

            soomlaProfile_PushEventInviteFinished(provider.ToString(), SocialActionType.INVITE.ToString(), requestId, jsonInvited.ToString(), payload);
        }
        protected override void _pushEventGetContactsFinished(Provider provider, SocialPageData <UserProfile> contactsPage, string payload)
        {
            if (SoomlaProfile.IsProviderNativelyImplemented(provider))
            {
                return;
            }
            List <JSONObject> profiles = new List <JSONObject>();

            foreach (var profile in contactsPage.PageData)
            {
                profiles.Add(profile.toJSONObject());
            }
            JSONObject contacts = new JSONObject(profiles.ToArray());

            soomlaProfile_PushEventGetContactsFinished(provider.ToString(), contacts.ToString(), payload, contactsPage.HasMore);
        }
        protected override UserProfile _getStoredUserProfile(Provider provider)
        {
            JSONObject upObj = null;
            AndroidJNI.PushLocalFrame(100);
            using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.UnitySoomlaProfile")) {
                string upJSON = ProfileJNIHandler.CallStatic<string>(jniSoomlaProfile, "getStoredUserProfile", provider.ToString());
                if(upJSON != null) {
                    upObj = new JSONObject(upJSON);
                }
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);

            if (upObj) {
                return new UserProfile(upObj);
            } else {
                return null;
            }
        }
Example #17
0
 protected override void _pushEventInviteFinished(Provider provider, string requestId, List <string> invitedIds, string payload)
 {
     if (SoomlaProfile.IsProviderNativelyImplemented(provider))
     {
         return;
     }
     AndroidJNI.PushLocalFrame(100);
     using (AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.ProfileEventHandler")) {
         List <JSONObject> invited = new List <JSONObject>();
         foreach (var id in invitedIds)
         {
             invited.Add(JSONObject.StringObject(id));
         }
         JSONObject jsonInvited = new JSONObject(invited.ToArray());
         ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "pushEventInviteFinished",
                                          provider.ToString(), SocialActionType.INVITE.ToString(), requestId, jsonInvited.ToString(), payload);
     }
     AndroidJNI.PopLocalFrame(IntPtr.Zero);
 }
        /// <summary>
        /// Logs the user into the given provider.
        /// Supported platforms: Facebook, Twitter, Google+
        /// </summary>
        /// <param name="provider">The provider to log in to.</param>
        /// <param name="payload">A string to receive when the function returns.</param>
        /// <param name="reward">A <c>Reward</c> to give the user after a successful login.</param>
        public static void Login(Provider provider, string payload = "", Reward reward = null)
        {
            SoomlaUtils.LogDebug(TAG, "Trying to login with provider " + provider.ToString());
            SocialProvider targetProvider = GetSocialProvider(provider);
            string         userPayload    = (payload == null) ? "" : payload;

            if (targetProvider == null)
            {
                SoomlaUtils.LogError(TAG, "Provider not supported or not set as active: " + provider.ToString());
                return;
            }

            if (targetProvider.IsNativelyImplemented())
            {
                //fallback to native
                string rewardId = reward != null ? reward.ID : "";
                instance._login(provider, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString());
            }

            else
            {
                setLoggedInForProvider(provider, false);
                ProfileEvents.OnLoginStarted(provider, userPayload);
                targetProvider.Login(
                    /* success */ () => {
                    targetProvider.GetUserProfile((UserProfile userProfile) => {
                        StoreUserProfile(userProfile);
                        setLoggedInForProvider(provider, true);
                        ProfileEvents.OnLoginFinished(userProfile, userPayload);
                        if (reward != null)
                        {
                            reward.Give();
                        }
                    }, (string message) => {
                        ProfileEvents.OnLoginFailed(provider, message, userPayload);
                    });
                },
                    /* fail */ (string message) => { ProfileEvents.OnLoginFailed(provider, message, userPayload); },
                    /* cancel */ () => { ProfileEvents.OnLoginCancelled(provider, userPayload); }
                    );
            }
        }
Example #19
0
        protected override void _pushEventGetContactsFinished(Provider provider, SocialPageData <UserProfile> contactsPage, string payload)
        {
            if (SoomlaProfile.IsProviderNativelyImplemented(provider))
            {
                return;
            }
            List <JSONObject> profiles = new List <JSONObject>();

            foreach (var profile in contactsPage.PageData)
            {
                profiles.Add(profile.toJSONObject());
            }
            JSONObject contacts = new JSONObject(profiles.ToArray());

            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.ProfileEventHandler")) {
                ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "pushEventGetContactsFinished",
                                                 provider.ToString(), contacts.ToString(), payload, contactsPage.HasMore);
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
        }
Example #20
0
        protected override void _pushEventGetFeedFinished(Provider provider, SocialPageData <String> feedPage, string payload)
        {
            if (SoomlaProfile.IsProviderNativelyImplemented(provider))
            {
                return;
            }
            List <JSONObject> feeds = new List <JSONObject>();

            foreach (var feed in feedPage.PageData)
            {
                feeds.Add(JSONObject.StringObject(feed));
            }
            JSONObject feedJson = new JSONObject(feeds.ToArray());

            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.ProfileEventHandler")) {
                ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "pushEventGetFeedFinished",
                                                 provider.ToString(), feedJson.ToString(), payload, feedPage.HasMore);
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
        }
Example #21
0
 protected override void _uploadImage(Provider provider, string message, string filePath, string payload)
 {
     soomlaProfile_UploadImage(provider.ToString(), message, filePath, payload);
 }
Example #22
0
 protected override void _invite(Provider provider, string inviteMessage, string dialogTitle, string payload)
 {
     soomlaProfile_Invite(provider.ToString(), inviteMessage, dialogTitle, payload);
 }
Example #23
0
 protected override void _updateStoryDialog(Provider provider, string name, string caption, string description,
                                            string link, string picture, string payload)
 {
     soomlaProfile_UpdateStoryDialog(provider.ToString(), name, caption, description, link, picture, payload);
 }
Example #24
0
 protected override void _updateStatus(Provider provider, string status, string payload,
                                       bool showConfirmation, string customMessage)
 {
     soomlaProfile_UpdateStatus(provider.ToString(), status, payload, showConfirmation, customMessage);
 }
Example #25
0
 protected override void _logout(Provider provider)
 {
     soomlaProfile_Logout(provider.ToString());
 }
		protected override void _pushEventGetFeedFinished(Provider provider ,SocialPageData<String> feedPage, string payload) {
			if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
			List<JSONObject> feeds = new List<JSONObject>();
			foreach (var feed in feedPage.PageData) {
				feeds.Add(JSONObject.StringObject(feed));
			}
			JSONObject jsonFeeds = new JSONObject(feeds.ToArray());
			soomlaProfile_PushEventGetFeedFinished(provider.ToString(), jsonFeeds.ToString(), payload, feedPage.HasMore);
		}
		protected override void _pushEventInviteFinished(Provider provider, string requestId, List<string> invitedIds, string payload) {
			if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.ProfileEventHandler")) {
				List<JSONObject> invited = new List<JSONObject>();
				foreach (var id in invitedIds) {
					invited.Add(JSONObject.StringObject(id));
				}
				JSONObject jsonInvited = new JSONObject(invited.ToArray());
				ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "pushEventInviteFinished",
				                                 provider.ToString(), SocialActionType.INVITE.ToString(), requestId, jsonInvited.ToString(), payload);
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
		}
 protected override void _pushEventLoginCancelled(Provider provider, bool autoLogin, string payload)
 {
     if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
     soomlaProfile_PushEventLoginCancelled(provider.ToString(), autoLogin, payload);
 }
 protected override void _pushEventGetContactsStarted(Provider provider, bool fromStart, string payload)
 {
     if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
     soomlaProfile_PushEventGetContactsStarted(provider.ToString(), fromStart, payload);
 }
		protected override bool _isLoggedIn(Provider provider){
			return soomlaProfile_IsLoggedIn(provider.ToString());
		}
 protected override void _pushEventSocialActionStarted(Provider provider, SocialActionType actionType, string payload)
 {
     if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
     soomlaProfile_PushEventSocialActionStarted(provider.ToString(), actionType.ToString(), payload);
 }
 protected override void _pushEventLogoutStarted(Provider provider)
 {
     if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
     soomlaProfile_PushEventLogoutStarted(provider.ToString());
 }
 protected override void _pushEventLogoutFailed(Provider provider, string message)
 {
     if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
     soomlaProfile_PushEventLogoutFailed(provider.ToString(), message);
 }
		private static string getLoggedInStorageKeyForProvider(Provider provider) {
			return DB_KEY_PREFIX + "." + provider.ToString() + ".loggedIn";
		}
		protected override void _updateStatusDialog(Provider provider, string link, string payload) {
			soomlaProfile_UpdateStatusDialog(provider.ToString(), link, payload);
		}
Example #36
0
        protected override void _uploadImage(Provider provider, string message, string fileName, byte[] imageBytes, int jpegQuality, string payload)
        {
            string base64Str = Convert.ToBase64String(imageBytes);

            soomlaProfile_UploadImage(provider.ToString(), message, fileName, base64Str, payload);
        }
		protected override void _pushEventInviteFinished(Provider provider, string requestId, List<string> invitedIds, string payload) {
			if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
			List<JSONObject> invited = new List<JSONObject>();
			foreach (var id in invitedIds) {
				invited.Add(JSONObject.StringObject(id));
			}
			JSONObject jsonInvited = new JSONObject(invited.ToArray());
			soomlaProfile_PushEventInviteFinished(provider.ToString(), SocialActionType.INVITE.ToString(), requestId, jsonInvited.ToString(), payload);
		}
Example #38
0
 protected override void _getContacts(Provider provider, string payload)
 {
     soomlaProfile_GetContacts(provider.ToString(), payload);
 }
		protected override void _pushEventSocialActionStarted(Provider provider, SocialActionType actionType, string payload) { 
			if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
			AndroidJNI.PushLocalFrame(100);
			using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.ProfileEventHandler")) {
				ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "pushEventSocialActionStarted",
				                                 provider.ToString(), actionType.ToString(), payload);
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
		}
Example #40
0
 protected override void _updateStatus(Provider provider, string status, string payload)
 {
     soomlaProfile_UpdateStatus(provider.ToString(), status, payload);
 }
Example #41
0
 protected override bool _isLoggedIn(Provider provider)
 {
     return(soomlaProfile_IsLoggedIn(provider.ToString()));
 }
        protected override UserProfile _getStoredUserProfile(Provider provider)
        {
            JSONObject upObj = null;

            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.UnitySoomlaProfile")) {
                string upJSON = ProfileJNIHandler.CallStatic <string>(jniSoomlaProfile, "getStoredUserProfile", provider.ToString());
                if (upJSON != null)
                {
                    upObj = new JSONObject(upJSON);
                }
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);

            if (upObj)
            {
                return(new UserProfile(upObj));
            }
            else
            {
                return(null);
            }
        }
Example #43
0
 protected override void _updateStatusDialog(Provider provider, string link, string payload)
 {
     soomlaProfile_UpdateStatusDialog(provider.ToString(), link, payload);
 }
        protected override bool _isLoggedIn(Provider provider)
        {
            bool loggedIn;

            AndroidJNI.PushLocalFrame(100);
            using (AndroidJavaClass unityActivityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
                using (AndroidJavaObject unityActivity = unityActivityClass.GetStatic <AndroidJavaObject>("currentActivity")) {
                    using (AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.UnitySoomlaProfile")) {
                        loggedIn = ProfileJNIHandler.CallStatic <bool>(jniSoomlaProfile, "isLoggedIn", unityActivity, provider.ToString());
                    }
                }
            }
            AndroidJNI.PopLocalFrame(IntPtr.Zero);
            return(loggedIn);
        }
Example #45
0
 protected override void _getFeed(Provider provider, bool fromStart, string payload)
 {
     soomlaProfile_GetFeed(provider.ToString(), fromStart, payload);
 }
 private static string getLoggedInStorageKeyForProvider(Provider provider)
 {
     return(DB_KEY_PREFIX + "." + provider.ToString() + ".loggedIn");
 }
Example #47
0
 protected override void _login(Provider provider, string payload)
 {
     soomlaProfile_Login(provider.ToString(), payload);
 }
		protected override void _pushEventInviteFailed(Provider provider, string message, string payload) { 
			if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
			soomlaProfile_PushEventInviteFailed(provider.ToString(), SocialActionType.INVITE.ToString(), message, payload);
		}
 protected override void _login(Provider provider, string payload)
 {
     AndroidJNI.PushLocalFrame(100);
     using (AndroidJavaClass unityActivityClass = new AndroidJavaClass("com.unity3d.player.UnityPlayer")) {
         using (AndroidJavaObject unityActivity = unityActivityClass.GetStatic <AndroidJavaObject>("currentActivity")) {
             using (AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.UnitySoomlaProfile")) {
                 ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "login", unityActivity, provider.ToString(), payload);
             }
         }
     }
     AndroidJNI.PopLocalFrame(IntPtr.Zero);
 }
Example #50
0
 protected override void _pushEventLogoutFinished(Provider provider)
 {
     if (SoomlaProfile.IsProviderNativelyImplemented(provider))
     {
         return;
     }
     AndroidJNI.PushLocalFrame(100);
     using (AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.ProfileEventHandler")) {
         ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "pushEventLogoutFinished", provider.ToString());
     }
     AndroidJNI.PopLocalFrame(IntPtr.Zero);
 }
 protected override void _updateStatusDialog(Provider provider, string link, string payload)
 {
     AndroidJNI.PushLocalFrame(100);
     using (AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.UnitySoomlaProfile")) {
         ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "updateStatusDialog", provider.ToString(), link, payload);
     }
     AndroidJNI.PopLocalFrame(IntPtr.Zero);
 }
		protected override void _updateStory(Provider provider, string message, string name, 
		                                     string caption, string description, string link,
		                                     string pictureUrl, string payload, 
		                                     bool showConfirmation, string customMessage) {
			soomlaProfile_UpdateStory(provider.ToString(), message, name, caption, description, link, pictureUrl, payload, showConfirmation, customMessage);
		}
Example #53
0
 protected override void _pushEventLoginFailed(Provider provider, string message, bool autoLogin, string payload)
 {
     if (SoomlaProfile.IsProviderNativelyImplemented(provider))
     {
         return;
     }
     AndroidJNI.PushLocalFrame(100);
     using (AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.ProfileEventHandler")) {
         ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "pushEventLoginFailed", provider.ToString(), message, autoLogin, payload);
     }
     AndroidJNI.PopLocalFrame(IntPtr.Zero);
 }
Example #54
0
 private static string keyUserProfile(Provider provider)
 {
     return(DB_KEY_PREFIX + "userprofile." + provider.ToString());
 }
		/** keys when running in editor **/
		private static string keyUserProfile(Provider provider) {
			return DB_KEY_PREFIX + ".userprofile." + provider.ToString();
		}
		protected override void _pushEventGetFeedFinished (Provider provider, SocialPageData<String> feedPage, string payload) {
			if (SoomlaProfile.IsProviderNativelyImplemented(provider)) return;
			List<JSONObject> feeds = new List<JSONObject>();
			foreach (var feed in feedPage.PageData) {
				feeds.Add(JSONObject.StringObject(feed));
			}
			JSONObject feedJson = new JSONObject(feeds.ToArray());

			AndroidJNI.PushLocalFrame(100);
			using (AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.ProfileEventHandler")) {
				ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "pushEventGetFeedFinished", 
				                                 provider.ToString(), feedJson.ToString(), payload, feedPage.HasMore);
			}
			AndroidJNI.PopLocalFrame(IntPtr.Zero);
		}
		private static void login(Provider provider, bool autoLogin, string payload="", Reward reward = null) {
			SoomlaUtils.LogDebug (TAG, "Trying to login with provider " + provider.ToString ());
			SocialProvider targetProvider = GetSocialProvider(provider);
			string userPayload = (payload == null) ? "" : payload;
			if (targetProvider == null)
			{
				SoomlaUtils.LogError(TAG, "Provider not supported or not set as active: " + provider.ToString());
				return;
			}

			if (targetProvider.IsNativelyImplemented())
			{
				//fallback to native
				string rewardId = reward != null ? reward.ID : "";
				instance._login(provider, ProfilePayload.ToJSONObj(userPayload, rewardId).ToString());
			}

			else
			{
				setLoggedInForProvider(provider, false);
				ProfileEvents.OnLoginStarted(provider, autoLogin, userPayload);
				targetProvider.Login(
					/* success */	() => {
					targetProvider.GetUserProfile((UserProfile userProfile) => {
						StoreUserProfile(userProfile);
						setLoggedInForProvider(provider, true);
						ProfileEvents.OnLoginFinished(userProfile, autoLogin, userPayload);
						if (reward != null) {
							reward.Give();
						}
					}, (string message) => {
						ProfileEvents.OnLoginFailed (provider, message, autoLogin, userPayload);
					});
				},
				/* fail */		(string message) => {  ProfileEvents.OnLoginFailed (provider, message, autoLogin, userPayload); },
				/* cancel */	() => {  ProfileEvents.OnLoginCancelled(provider, autoLogin, userPayload); }
				);
			}
		}
		protected override void _updateStatus(Provider provider, string status, string payload, 
		                                      bool showConfirmation, string customMessage) {
			soomlaProfile_UpdateStatus(provider.ToString(), status, payload, showConfirmation, customMessage); 
		}