public SocialActionFailedEvent(Provider provider, SocialActionType socialType, String errorDescription, String payload) : base(provider) { this.provider = provider; this.SocialType = socialType; this.payload = payload; this.ErrorDescription = errorDescription; }
public GetScoresFailedEvent(Provider provider, Leaderboard from, bool fromStart, string errorDescription, string payload) : base(provider, payload) { this.From = from; this.FromStart = fromStart; this.ErrorDescription = errorDescription; }
/// <summary> /// Constructor. /// </summary> /// <param name="id"><c>Gate</c> ID.</param> /// <param name="provider">Social provider.</param> /// <param name="fileName">Name of file to upload.</param> /// <param name="message">Message.</param> /// <param name="texture">Texture.</param> public SocialUploadGate(string id, Provider provider, string fileName, string message, Texture2D texture) : base(id, provider) { FileName = fileName; Message = message; ImgTexture = texture; }
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); }
/// <summary> /// Constructor. /// </summary> /// <param name="provider">The provider this <c>UserProfile</c> belongs to.</param> /// <param name="profileId">A unique ID that identifies the current user with the provider.</param> /// <param name="username">The username of the current user in the provider.</param> /// <param name="extra">Additional info provided by SN.</param> protected UserProfile(Provider provider, string profileId, string username, Dictionary<String, JSONObject> extra) { this.Provider = provider; this.ProfileId = profileId; this.Username = username; this.Extra = extra; }
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 _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 _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 _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 _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); }
/// <summary> /// Constructor. /// </summary> /// <param name="id"><c>Gate</c> ID.</param> /// <param name="provider">Social provider.</param> /// <param name="message">Message for the story.</param> /// <param name="name">Story name.</param> /// <param name="caption">Caption for the story image.</param> /// <param name="link">Link for the story.</param> /// <param name="imgUrl">Image URL for the story.</param> public SocialStoryGate(string id, Provider provider, string message, string storyName, string caption, string link, string imgUrl) : base(id, provider) { Message = message; StoreName = storyName; Caption = caption; Link = link; ImgUrl = imgUrl; }
protected override void _updateStory(Provider provider, string message, string name, string caption, string description, string link, string pictureUrl, string payload){ AndroidJNI.PushLocalFrame(100); using(AndroidJavaClass jniSoomlaProfile = new AndroidJavaClass("com.soomla.profile.unity.UnitySoomlaProfile")) { ProfileJNIHandler.CallStaticVoid(jniSoomlaProfile, "updateStory", provider.ToString(), message, name, caption, description, link, pictureUrl, 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 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); }
/// <summary> /// Constructor. /// Generates an instance of <c>UserProfile</c> from the given <c>JSONObject</c>. /// </summary> /// <param name="jsonUP">A JSONObject representation of the wanted <c>UserProfile</c>.</param> public UserProfile(JSONObject jsonUP) { this.Provider = Provider.fromString(jsonUP[PJSONConsts.UP_PROVIDER].str); this.Username = JSONObject.DecodeJsString(jsonUP[PJSONConsts.UP_USERNAME].str); this.ProfileId = JSONObject.DecodeJsString(jsonUP[PJSONConsts.UP_PROFILEID].str); if (jsonUP[PJSONConsts.UP_FIRSTNAME] != null && jsonUP[PJSONConsts.UP_FIRSTNAME].type == JSONObject.Type.STRING) { this.FirstName = JSONObject.DecodeJsString(jsonUP[PJSONConsts.UP_FIRSTNAME].str); } else { this.FirstName = ""; } if (jsonUP[PJSONConsts.UP_LASTNAME] != null && jsonUP[PJSONConsts.UP_LASTNAME].type == JSONObject.Type.STRING) { this.LastName = JSONObject.DecodeJsString(jsonUP[PJSONConsts.UP_LASTNAME].str); } else { this.LastName = ""; } if (jsonUP[PJSONConsts.UP_EMAIL] != null && jsonUP[PJSONConsts.UP_EMAIL].type == JSONObject.Type.STRING) { this.Email = JSONObject.DecodeJsString(jsonUP[PJSONConsts.UP_EMAIL].str); } else { this.Email = ""; } if (jsonUP[PJSONConsts.UP_AVATAR] != null && jsonUP[PJSONConsts.UP_AVATAR].type == JSONObject.Type.STRING) { this.AvatarLink = JSONObject.DecodeJsString(jsonUP[PJSONConsts.UP_AVATAR].str); } else { this.AvatarLink = ""; } if (jsonUP[PJSONConsts.UP_LOCATION] != null && jsonUP[PJSONConsts.UP_LOCATION].type == JSONObject.Type.STRING) { this.Location = JSONObject.DecodeJsString(jsonUP[PJSONConsts.UP_LOCATION].str); } else { this.Location = ""; } if (jsonUP[PJSONConsts.UP_GENDER] != null && jsonUP[PJSONConsts.UP_GENDER].type == JSONObject.Type.STRING) { this.Gender = JSONObject.DecodeJsString(jsonUP[PJSONConsts.UP_GENDER].str); } else { this.Gender = ""; } if (jsonUP[PJSONConsts.UP_LANGUAGE] != null && jsonUP[PJSONConsts.UP_LANGUAGE].type == JSONObject.Type.STRING) { this.Language = JSONObject.DecodeJsString(jsonUP[PJSONConsts.UP_LANGUAGE].str); } else { this.Language = ""; } if (jsonUP[PJSONConsts.UP_BIRTHDAY] != null && jsonUP[PJSONConsts.UP_BIRTHDAY].type == JSONObject.Type.STRING) { this.Birthday = JSONObject.DecodeJsString(jsonUP[PJSONConsts.UP_BIRTHDAY].str); } else { this.Birthday = ""; } this.Extra = new Dictionary<String, JSONObject>(); if (jsonUP[PJSONConsts.UP_EXTRA] != null && jsonUP[PJSONConsts.UP_EXTRA].type == JSONObject.Type.OBJECT) { foreach (String key in jsonUP[PJSONConsts.UP_EXTRA].keys) { this.Extra.Add(key, jsonUP[PJSONConsts.UP_EXTRA][key]); } } }
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 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; }
/// <summary> /// Get the current active access token. /// Supported platforms: Facebook, Twitter (returns a json string with token and token_secret), Google+ /// </summary> /// <returns>If is logged into the specified provider, returns the active access tkoen.</returns> /// <param name="provider">The provider to get the active access token for.</param> public static string GetAccessToken(Provider provider) { SocialProvider targetProvider = GetSocialProvider(provider); if (targetProvider == null) return null; if (targetProvider.IsNativelyImplemented ()) { //fallback to native return instance._getAccessToken(provider); } return targetProvider.GetAccessToken(); }
public Leaderboard(JSONObject jsonLB) { this.ID = jsonLB[PJSONConsts.UP_IDENTIFIER].str; this.Provider = Provider.fromString(jsonLB[PJSONConsts.UP_PROVIDER].str); if (jsonLB[PJSONConsts.UP_NAME] != null && jsonLB[PJSONConsts.UP_NAME].type == JSONObject.Type.STRING) { this.Name = jsonLB[PJSONConsts.UP_NAME].str; } else { this.Name = ""; } if (jsonLB[PJSONConsts.UP_ICON_URL] != null && jsonLB[PJSONConsts.UP_ICON_URL].type == JSONObject.Type.STRING) { this.IconURL = jsonLB[PJSONConsts.UP_ICON_URL].str; } else { this.IconURL = ""; } }
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); }
/// <summary> /// Constructor. /// Generates an instance of <c>UserProfile</c> from the given <c>JSONObject</c>. /// </summary> /// <param name="jsonUP">A JSONObject representation of the wanted <c>UserProfile</c>.</param> public UserProfile(JSONObject jsonUP) { this.Provider = Provider.fromString(jsonUP[PJSONConsts.UP_PROVIDER].str); this.Username = jsonUP[PJSONConsts.UP_USERNAME].str; this.ProfileId = jsonUP[PJSONConsts.UP_PROFILEID].str; if (jsonUP[PJSONConsts.UP_FIRSTNAME]) { this.FirstName = jsonUP[PJSONConsts.UP_FIRSTNAME].str; } else { this.FirstName = ""; } if (jsonUP[PJSONConsts.UP_LASTNAME]) { this.LastName = jsonUP[PJSONConsts.UP_LASTNAME].str; } else { this.LastName = ""; } if (jsonUP[PJSONConsts.UP_EMAIL]) { this.Email = jsonUP[PJSONConsts.UP_EMAIL].str; } else { this.Email = ""; } if (jsonUP[PJSONConsts.UP_AVATAR]) { this.AvatarLink = jsonUP[PJSONConsts.UP_AVATAR].str; } else { this.AvatarLink = ""; } if (jsonUP[PJSONConsts.UP_LOCATION]) { this.Location = jsonUP[PJSONConsts.UP_LOCATION].str; } else { this.Location = ""; } if (jsonUP[PJSONConsts.UP_GENDER]) { this.Gender = jsonUP[PJSONConsts.UP_GENDER].str; } else { this.Gender = ""; } if (jsonUP[PJSONConsts.UP_LANGUAGE]) { this.Language = jsonUP[PJSONConsts.UP_LANGUAGE].str; } else { this.Language = ""; } if (jsonUP[PJSONConsts.UP_BIRTHDAY]) { this.Birthday = jsonUP[PJSONConsts.UP_BIRTHDAY].str; } else { this.Birthday = ""; } }
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; } }
/// <summary> /// Fetches UserProfiles of contacts of the current user. /// Supported platforms: Facebook, Twitter, Google+. /// Missing contact information for Twitter: email, gender, birthday. /// Missing contact information for Google+: username, email, gender, bithday /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="provider">The <c>Provider</c> to fetch contacts from.</param> /// <param name="fromStart">Should we reset pagination or request the next page.</param> /// <param name="payload">A string to receive when the function returns.</param> public static void GetContacts(Provider provider, bool fromStart = false, string payload="") { SocialProvider targetProvider = GetSocialProvider(provider); string userPayload = (payload == null) ? "" : payload; if (targetProvider == null) return; if (targetProvider.IsNativelyImplemented()) { //fallback to native instance._getContacts(provider, fromStart, ProfilePayload.ToJSONObj(userPayload).ToString()); } else { ProfileEvents.OnGetContactsStarted(provider, fromStart, userPayload); targetProvider.GetContacts(fromStart, /* success */ (SocialPageData<UserProfile> contactsData) => { ProfileEvents.OnGetContactsFinished(provider, contactsData, userPayload); }, /* fail */ (string message) => { ProfileEvents.OnGetContactsFailed(provider, message, fromStart, userPayload); } ); } }
protected virtual void _pushEventLoginFailed(Provider provider, string message, bool autoLogin, string payload) { }
protected virtual void _getFeed(Provider provider, bool fromStart, string payload) { }
protected virtual UserProfile _getStoredUserProfile(Provider provider) { #if UNITY_EDITOR string key = keyUserProfile(provider); string value = PlayerPrefs.GetString (key); if (!string.IsNullOrEmpty(value)) { return new UserProfile (new JSONObject (value)); } #endif return null; }
/// <summary> /// Fetches the saved user profile for the given provider. UserProfiles are automatically /// saved in the local storage for a provider after a successful login. /// /// NOTE: This operation requires a successful login. /// </summary> /// <returns>The stored user profile.</returns> /// <param name="provider">The provider to fetch UserProfile from.</param> public static UserProfile GetStoredUserProfile(Provider provider) { return(instance._getStoredUserProfile(provider)); }
protected virtual void _uploadImage(Provider provider, string message, string fileName, byte[] imageBytes, int jpegQuality, string payload, bool showConfirmation, string customMessage) { }
protected virtual void _updateStory(Provider provider, string message, string name, string caption, string description, string link, string pictureUrl, string payload) { }
protected virtual void _pushEventLogoutStarted(Provider provider) { }
protected virtual void _pushEventGetFeedFinished(Provider provider, SocialPageData <String> feedPage, string payload) { }
protected virtual void _pushEventGetContactsFinished(Provider provider, SocialPageData <UserProfile> contactsPage, string payload) { }
protected virtual void _pushEventInviteFinished(Provider provider, string requestId, List <string> invitedIds, string payload) { }
protected virtual void _pushEventGetFeedFailed(Provider provider, string message, bool fromStart, string payload) { }
/// <summary> /// Uploads an image to the user's social page on the given Provider. /// Supported platforms: Facebook, Twitter, Google+ /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="provider">The <c>Provider</c> the given image should be uploaded to.</param> /// <param name="message">Message to post with the image.</param> /// <param name="fileName">Name of image file with extension (jpeg/pgn).</param> /// <param name="tex2D">Texture2D for image.</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 upload.</param> public static void UploadImage(Provider provider, string message, string fileName, Texture2D tex2D, string payload = "", Reward reward = null) { UploadImage(provider, message, fileName, GetImageBytesFromTexture(fileName, tex2D), 100, payload, reward); }
protected virtual void _pushEventInviteFailed(Provider provider, string message, string payload) { }
protected virtual void _pushEventLogoutFinished(Provider provider) { }
protected virtual void _getContacts(Provider provider, string payload) { }
protected virtual bool _isLoggedIn(Provider provider) { return(false); }
protected virtual void _uploadImage(Provider provider, string message, string fileName, byte[] imageBytes, int jpegQuality, string payload) { }
protected virtual void _login(Provider provider, string payload) { }
protected virtual void _updateStatus(Provider provider, string status, string payload) { }
protected virtual void _pushEventLoginCancelled(Provider provider, bool autoLogin, string payload) { }
protected virtual void _logout(Provider provider) { }
protected virtual void _pushEventGetContactsStarted(Provider provider, bool fromStart, string payload) { }
protected virtual void _pushEventSocialActionFailed(Provider provider, SocialActionType actionType, string message, string payload) { }
protected virtual void _pushEventSocialActionCancelled(Provider provider, SocialActionType actionType, string payload) { }
/// <summary> /// Uploads the current screen shot image to the user's social page on the given Provider. /// Supported platforms: Facebook /// /// NOTE: This operation requires a successful login. /// </summary> /// <param name="mb">Mb.</param> /// <param name="provider">The <c>Provider</c> the given screenshot should be uploaded to.</param> /// <param name="title">The title of the screenshot.</param> /// <param name="message">Message to post with the screenshot.</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 upload.</param> public static void UploadCurrentScreenShot(MonoBehaviour mb, Provider provider, string title, string message, string payload = "", Reward reward = null) { mb.StartCoroutine(TakeScreenshot(provider, title, message, payload, reward)); }
protected virtual void _pushEventLogoutFailed(Provider provider, string message) { }
protected virtual void _getContacts(Provider provider, bool fromStart, string payload) { }
private static string keyUserProfile(Provider provider) { return(DB_KEY_PREFIX + "userprofile." + provider.ToString()); }
protected virtual void _invite(Provider provider, string inviteMessage, string dialogTitle, string payload) { }
protected virtual void _invite(Provider provider, string inviteMessage, string dialogTitle, string payload) { }
private static SocialProvider GetSocialProvider (Provider provider) { SocialProvider result = null; providers.TryGetValue(provider, out result); // if (result == null) { // throw new ProviderNotFoundException(); // } return result; }
protected virtual void _pushEventInviteCancelled(Provider provider, string payload) { }