Exemplo n.º 1
0
        /// <summary>
        /// Handles an <c>onSocialActionCancelled</c> event
        /// </summary>
        /// <param name="message">
        /// Will contain a numeric representation of <c>Provider</c>
        /// numeric representation of <c>SocialActionType</c> and payload</param>
        public void onSocialActionCancelled(String message)
        {
            SoomlaUtils.LogDebug(TAG, "SOOMLA/UNITY onSocialActionCancelled");

            JSONObject eventJson = new JSONObject(message);

            Provider         provider     = Provider.fromInt((int)eventJson["provider"].n);
            SocialActionType socialAction = SocialActionType.fromInt((int)eventJson["socialActionType"].n);

            JSONObject payloadJSON = new JSONObject(eventJson ["payload"].str);

            ProfileEvents.OnSocialActionCancelled(provider, socialAction, ProfilePayload.GetUserPayload(payloadJSON));
            //ProfileEvents.OnSocialActionCancelled (new SocialActionCancelledEvent(provider, socialAction, ProfilePayload.GetUserPayload(payloadJSON)));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Posts a full story to the user's social page on the given Provider with confirmation dialog.
        /// A story contains a title, description, image and more.
        /// Supported platforms: Facebook (full support),
        /// Twitter and Google+ (partial support - message and link only)
        ///
        /// NOTE: This operation requires a successful login.
        /// </summary>
        /// <param name="provider">The <c>Provider</c> the given story should be posted to.</param>
        /// <param name="message">A message that will be shown along with the story.</param>
        /// <param name="name">The name (title) of the story.</param>
        /// <param name="caption">A caption.</param>
        /// <param name="description">A description.</param>
        /// <param name="link">A link to a web page.</param>
        /// <param name="pictureUrl">A link to an image on the web.</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 post.</param>
        /// <param name="customMessage">The message to show in the dialog</param>
        public static void UpdateStoryWithConfirmation(Provider provider, string message, string name,
                                                       string caption, string description, string link, string pictureUrl,
                                                       string payload       = "", Reward reward = null,
                                                       string customMessage = null)
        {
            SocialProvider targetProvider = GetSocialProvider(provider);
            string         userPayload    = (payload == null) ? "" : payload;

            if (targetProvider == null)
            {
                return;
            }

            if (targetProvider.IsNativelyImplemented())
            {
                //fallback to native
                string rewardId = reward != null ? reward.ID: "";
                instance._updateStory(provider, message, name, caption, description, link, pictureUrl,
                                      ProfilePayload.ToJSONObj(userPayload, rewardId).ToString(), true, customMessage);
            }

            else
            {
                // TODO: Support showConfirmation
                ProfileEvents.OnSocialActionStarted(provider, SocialActionType.UPDATE_STORY, userPayload);
                targetProvider.UpdateStory(message, name, caption, link, pictureUrl,
                                           /* success */ () => {
                    if (reward != null)
                    {
                        reward.Give();
                    }
                    ProfileEvents.OnSocialActionFinished(provider, SocialActionType.UPDATE_STORY, userPayload);
                },
                                           /* fail */ (string error) => { ProfileEvents.OnSocialActionFailed(provider, SocialActionType.UPDATE_STORY, error, userPayload); },
                                           /* cancel */ () => { ProfileEvents.OnSocialActionCancelled(provider, SocialActionType.UPDATE_STORY, userPayload); }
                                           );
            }
        }
Exemplo n.º 3
0
//		public static void UploadImage(Provider provider, string message, string filename,
//		                               byte[] imageBytes, int quality, Reward reward) {
//			instance._uploadImage(provider, message, filename, imageBytes, quality, reward);
//		}
//

        /// <summary>
        /// Uploads an image to the user's social page on the given Provider.
        /// Supported platforms: Facebook
        ///
        /// 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="tex2D">Texture2D for image.</param>
        /// <param name="fileName">Name of image file.</param>
        /// <param name="message">Message to post with the 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, Texture2D tex2D, string fileName, string message, string payload = "",
                                       Reward reward = null)
        {
            SocialProvider targetProvider = GetSocialProvider(provider);
            string         userPayload    = (payload == null) ? "" : payload;

            if (targetProvider == null)
            {
                return;
            }

            if (targetProvider.IsNativelyImplemented())
            {
                //fallback to native
                ProfileEvents.OnSocialActionFailed(provider,
                                                   SocialActionType.UPLOAD_IMAGE,
                                                   "Image uploading is not supported with Texture for natively implemented social providers",
                                                   userPayload);
            }

            else
            {
                ProfileEvents.OnSocialActionStarted(provider, SocialActionType.UPLOAD_IMAGE, userPayload);
                targetProvider.UploadImage(tex2D.EncodeToPNG(), fileName, message,
                                           /* success */ () => {
                    ProfileEvents.OnSocialActionFinished(provider, SocialActionType.UPLOAD_IMAGE, userPayload);
                    if (reward != null)
                    {
                        reward.Give();
                    }
                },
                                           /* fail */ (string error) => { ProfileEvents.OnSocialActionFailed(provider, SocialActionType.UPLOAD_IMAGE, error, userPayload); },
                                           /* cancel */ () => { ProfileEvents.OnSocialActionCancelled(provider, SocialActionType.UPLOAD_IMAGE, userPayload); }
                                           );
            }
        }