Esempio n. 1
0
        public void LoadImage(string url, Action <AN_ImageLoadResult> callback)
        {
            var error  = new SA_Error(1, "Can only be used on a real device");
            var result = new AN_ImageLoadResult(error);

            callback.Invoke(result);
        }
Esempio n. 2
0
        //--------------------------------------
        // GKPlayer
        //--------------------------------------


        public void GKPlayerLoadPhotoForSize(string playerId, int size, Action <ISN_GKImageLoadResult> callback)
        {
            var error  = new SA_Error(1, "Can only be used on a real device");
            var result = new ISN_GKImageLoadResult(error);

            callback.Invoke(result);
        }
Esempio n. 3
0
 public void OnAfterDeserialize()
 {
     if (Data == null)
     {
         m_error = new SA_Error(NATIVE_API_NULL_OBJECT_RESPONCE, "Native API responded with a null object");
     }
 }
        public void GenerateIdentityVerificationSignatureWithCompletionHandler(Action <ISN_GKIdentityVerificationSignatureResult> callback)
        {
            SA_Error error  = new SA_Error(1, "Can't be used inside Unty editor");
            var      result = new ISN_GKIdentityVerificationSignatureResult(error);

            callback.Invoke(result);
        }
Esempio n. 5
0
        private void LoadErrorCallback(string message)
        {
            var error = new SA_Error(1, message);

            m_loadCallback.Invoke(new SA_Result(error));
            m_loadCallback = null;
        }
Esempio n. 6
0
 protected void HandleAdFailedToLoad(object sender, AdFailedToLoadEventArgs e)
 {
     SA_MainThreadDispatcher.Enqueue(() => {
         var error = new SA_Error(1, e.Message);
         m_loadCallback.Invoke(new SA_Result(error));
         m_loadCallback = null;
     });
 }
 public UM_MediaResult(UM_Media media)
 {
     m_media = media;
     if (m_media == null)
     {
         m_error = new SA_Error(100, "No Media");
     }
 }
Esempio n. 8
0
            private void OnInstaPostFailed(string data)
            {
                int code = Convert.ToInt32(data);

                SA_Error  error  = new SA_Error(code, "Posting Failed");
                SA_Result result = new SA_Result(error);

                OnPostResult(result);
            }
        public void OnAfterDeserialize()
        {
            var serializableAttribute = Attribute.GetCustomAttribute(typeof(T), typeof(SerializableAttribute));

            Assert.IsNotNull(serializableAttribute, "AN_LinkedObjectResult Generic type: " + typeof(T).Name + " is not Serializable!");

            if (Data == null)
            {
                m_error = new SA_Error(NATIVE_API_NULL_OBJECT_RESPONSE, "Native API responded with a null object");
            }
        }
Esempio n. 10
0
 /// <summary>
 /// Remove event though EventKit by it's identifier.
 /// <summary>
 public void RemoveEvent(Action <SA_Result> callback, string identifier)
 {
     if (string.IsNullOrEmpty(identifier))
     {
         SA_Error  error  = new SA_Error(1, "Identifier parameter is empty or null.");
         SA_Result result = new SA_Result(error);
         callback.Invoke(result);
     }
     #if UNITY_IPHONE && EVENT_KIT_ENABLED
     _ISN_RemoveEvent(ISN_MonoPCallback.ActionToIntPtr <SA_Result>(callback), identifier);
     #endif
 }
Esempio n. 11
0
 public SA_FB_GetUserResult(IResult graphResult) : base(graphResult)
 {
     if (m_error == null)
     {
         try {
             var JSON = Json.Deserialize(RawResult) as IDictionary;
             m_user = new SA_FB_User(JSON);
         }
         catch (Exception ex) {
             m_error = new SA_Error(5, "Failed to parse user data " + ex.Message);
         }
     }
 }
Esempio n. 12
0
        protected override void ConnectToService(string appId, Action <SA_Result> callback)
        {
#if SA_UNITY_ADS_INSTALLED
            m_initCallback = callback;
            Monetization.Initialize(appId, UM_UnityAdsSettings.Instance.TestMode);

            SA_Coroutine.Start(WaitForInitialization());
#else
            var error  = new SA_Error(1, "Unity Ads SDK is missing");
            var result = new SA_Result(error);
            callback.Invoke(result);
#endif
        }
Esempio n. 13
0
        protected override void AddNotificationRequestInternal(UM_NotificationRequest request, Action <SA_Result> callback)
        {
            try
            {
                var builder = new AN_NotificationCompat.Builder();
                builder.SetContentTitle(request.Content.Title);
                builder.SetContentText(request.Content.Body);
                if (request.Content.BadgeNumber != -1)
                {
                    builder.SetNumber(request.Content.BadgeNumber);
                }

                if (string.IsNullOrEmpty(request.Content.SoundName))
                {
                    builder.SetDefaults(AN_Notification.DEFAULT_LIGHTS | AN_Notification.DEFAULT_SOUND);
                }
                else
                {
                    string soundName = SA_AssetDatabase.GetAssetNameWithoutExtension(request.Content.SoundName);
                    builder.SetSound(soundName);
                }


                if (!string.IsNullOrEmpty(request.Content.IconName))
                {
                    string iconName = SA_AssetDatabase.GetAssetNameWithoutExtension(request.Content.IconName);
                    builder.SetSmallIcon(iconName);
                }

                if (request.Content.LargeIcon != null)
                {
                    builder.SetLargeIcon(request.Content.LargeIcon);
                }


                UM_TimeIntervalNotificationTrigger timeIntervalTrigger = (UM_TimeIntervalNotificationTrigger)request.Trigger;

                var trigger = new AN_AlarmNotificationTrigger();
                trigger.SetDate(TimeSpan.FromSeconds(timeIntervalTrigger.Interval));
                trigger.SerRepeating(timeIntervalTrigger.Repeating);

                var android_request = new AN_NotificationRequest(request.Identifier, builder, trigger);

                AN_NotificationManager.Schedule(android_request);

                callback.Invoke(new SA_Result());
            } catch (Exception ex) {
                var error = new SA_Error(100, ex.Message);
                callback.Invoke(new SA_Result(error));
            }
        }
Esempio n. 14
0
 public override void RequestAuthorization(Action <SA_Result> callback)
 {
     AN_PermissionsUtility.TryToResolvePermission(AMM_ManifestPermission.WAKE_LOCK, (granted) => {
         if (granted)
         {
             callback.Invoke(new SA_Result());
         }
         else
         {
             var error = new SA_Error(100, "User declined");
             callback.Invoke(new SA_Result(error));
         }
     });
 }
        //--------------------------------------
        //  UM_AbstractInAppClient
        //--------------------------------------

        protected override void ConnectToService(Action <SA_Result> callback)
        {
            AN_Billing.Connect((result) => {
                if (!result.IsInAppsAPIAvalible && !result.IsSubsAPIAvalible)
                {
                    var error            = new SA_Error(100, "Current device does not support InApps");
                    var connectionResult = new SA_Result(error);
                    callback.Invoke(connectionResult);
                    return;
                }

                callback.Invoke(result);
            });
        }
 public SA_FB_GetProfileImageUrlResult(IResult graphResult) : base(graphResult)
 {
     if (m_error == null)
     {
         try {
             IDictionary JSON = Json.Deserialize(RawResult) as IDictionary;
             var         user = new SA_FB_User(JSON);
             m_url = user.PictureUrl;
         }
         catch (Exception ex) {
             m_error = new SA_Error(5, "Failed to parse user data " + ex.Message);
         }
     }
 }
 public void GoogleSignInClient_SilentSignIn(AN_GoogleSignInClient client, Action <AN_GoogleSignInResult> callback)
 {
     SA_Coroutine.WaitForSeconds(1, () => {
         if (m_canDoSilentSignedIn)
         {
             m_alreadySignedIn = true;
             callback.Invoke(new AN_GoogleSignInResult(new AN_GoogleSignInAccount()));
         }
         else
         {
             var error = new SA_Error((int)AN_CommonStatusCodes.SIGN_IN_REQUIRED, "SIGN_IN_REQUIRED");
             callback.Invoke(new AN_GoogleSignInResult(error));
         }
     });
 }
Esempio n. 18
0
        public static void PickImageFromGallery(int maxSize, AN_GalleryChooseType type, bool allowMultiSelect, Action <AN_GalleryPickResult> callback)
        {
            if (Application.isEditor)
            {
                SA_Coroutine.WaitForSeconds(1, () => {
                    var error = new SA_Error(100, "Gallery does not available on current device");
                    callback.Invoke(new AN_GalleryPickResult(error));
                });
                return;
            }

            int chooserType = (int)type;

            AN_Java.Bridge.CallStaticWithCallback(ANDROID_CLASS, "PickImageFromGallery", callback, maxSize, chooserType, allowMultiSelect);
        }
 public void LoadCurrentPlayerScore(string leaderboardId, UM_LeaderboardTimeSpan span, UM_LeaderboardCollection collection, Action <UM_ScoreLoadResult> callback)
 {
     UM_EditorAPIEmulator.WaitForNetwork(() => {
         if (UM_EditorAPIEmulator.HasKey(leaderboardId))
         {
             string json       = UM_EditorAPIEmulator.GetString(leaderboardId);
             UM_Score um_score = JsonUtility.FromJson <UM_Score>(json);
             callback.Invoke(new UM_ScoreLoadResult(um_score));
         }
         else
         {
             var error = new SA_Error(100, "Leaderboard with id: " + leaderboardId + " does not have any scores yet.");
             callback.Invoke(new UM_ScoreLoadResult(error));
         }
     });
 }
Esempio n. 20
0
        public static void SaveImageToGallery(Texture2D image, string name, string appDirectory, AN_GalleryFormat format, Action <AN_GallerySaveResult> callback)
        {
            string base64     = image.ToBase64String();
            int    saveFormat = (int)format;

            if (Application.isEditor)
            {
                SA_Coroutine.WaitForSeconds(1, () => {
                    var error = new SA_Error(100, "Gallery does not avaliable on current device");
                    callback.Invoke(new AN_GallerySaveResult(error));
                });
                return;
            }


            AN_Java.Bridge.CallStaticWithCallback(ANDROID_CLASS, "SaveImageToGallery", callback, base64, appDirectory, name, saveFormat);
        }
        public SA_FB_GraphFriendsListResult(IGraphResult graphResult) : base(graphResult) {
            if (m_error == null) {
                try {
                    IDictionary JSON = Json.Deserialize(RawResult) as IDictionary;
                    IDictionary body = JSON[FriendsListKey] as IDictionary;


                    if(body.Contains("summary")) {
                        IDictionary summary = body["summary"] as IDictionary;
                        if(summary.Contains("total_count")) {
                            m_totalFriendsCount = Convert.ToInt32(summary["total_count"]);
                        }
                    }

                } catch (Exception ex) {
                    m_error = new SA_Error(5, "Failed to parse friends data " + ex.Message);
                }
            }
        }
        public SA_FB_GraphInvitableFriendsListResult(IGraphResult graphResult) : base(graphResult)
        {
            if (m_error == null)
            {
                try {
                    IDictionary RAW     = Json.Deserialize(RawResult) as IDictionary;
                    IDictionary friends = RAW[FriendsListKey] as IDictionary;
                    IList       flist   = friends["data"] as IList;

                    for (int i = 0; i < flist.Count; i++)
                    {
                        SA_FB_User user = new SA_FB_User(flist[i] as IDictionary);
                        m_users.Add(user);
                    }

                    ParseResultId(RAW);
                    ParsePaginatedResult(friends);
                } catch (Exception ex) {
                    m_error = new SA_Error(5, "Failed to parse friends data " + ex.Message);
                }
            }
        }
Esempio n. 23
0
        public void LoadFromPlayerPrefs(UM_iSavedGameMetadata game, bool parseMeta, Action <UM_SavedGameDataLoadResult> callback)
        {
            var editorGamesList = LoadSavesList();
            var editorGame      = editorGamesList.GetByName(game.Name);

            UM_SavedGameDataLoadResult loadResult;

            if (editorGame != null)
            {
                var BytesArrayData = editorGame.GameData.ToBytes();
                if (parseMeta)
                {
                    var meta = new UM_SaveInfo();
                    meta.SetProgressValue(BitConverter.ToInt64(BytesArrayData, 0));
                    meta.SetPlayedTimeMillis(BitConverter.ToInt64(BytesArrayData, 8));

                    var userData = new byte[BytesArrayData.Length - 16];
                    Array.Copy(BytesArrayData, 16, userData, 0, userData.Length);
                    loadResult = new UM_SavedGameDataLoadResult(userData, meta);
                }
                else
                {
                    loadResult = new UM_SavedGameDataLoadResult(BytesArrayData, new UM_SaveInfo());
                }
            }
            else
            {
                var error = new SA_Error(100, "Saved game with name: " + game.Name + " wasn't found");
                loadResult = new UM_SavedGameDataLoadResult(error);
            }

            EditorSaveGames(editorGamesList);

            SA_Coroutine.WaitForSeconds(1.5f, () =>
            {
                callback.Invoke(loadResult);
            });
        }
Esempio n. 24
0
        //--------------------------------------
        // Public Methods
        //--------------------------------------

        /// <summary>
        /// Presents a view controller modally.
        ///
        /// If you configured the view controller to use <see cref="ISN_UIImagePickerControllerSourceType.Camera"/>,
        /// the <see cref="ISN_AVMediaType.Video"/> permission will be checked automatically,
        /// before presenting view controller. You can always do this yourself using the
        /// <see cref="ISN_AVCaptureDevice.RequestAccess"/>
        /// </summary>
        /// <param name="callback">Callback.</param>
        public void Present(Action <ISN_UIPickerControllerResult> callback)
        {
            //Need to make sure we have a permission for that
            if (m_request.m_sourceType == ISN_UIImagePickerControllerSourceType.Camera)
            {
                ISN_AVCaptureDevice.RequestAccess(ISN_AVMediaType.Video, (status) => {
                    if (status == ISN_AVAuthorizationStatus.Authorized)
                    {
                        StartPresenting(callback);
                    }
                    else
                    {
                        var error  = new SA_Error(1, "AVMediaType.Video Permission is missing");
                        var result = new ISN_UIPickerControllerResult(error);
                        callback.Invoke(result);
                    }
                });
            }
            else
            {
                StartPresenting(callback);
            }
        }
Esempio n. 25
0
        public void Increment(string achievementId, int numSteps, Action <SA_Result> callback)
        {
            //We need to caclulate PercentComplete.
            //Let's see if we have an achivement info already
            UM_iAchievement achievement = GetAchievementById(achievementId);

            if (achievement != null)
            {
                Increment(achievement, numSteps, callback);
            }
            else
            {
                Load((result) => {
                    if (result.IsSucceeded)
                    {
                        //It should be cached at this point already
                        achievement = GetAchievementById(achievementId);
                        if (achievement == null)
                        {
                            ISN_GKAchievement iSN_achievement = new ISN_GKAchievement(achievementId);
                            var iosAchievement = new UM_IOSAchievement(iSN_achievement);
                            SetAchievementCahce(iosAchievement);

                            achievement = iosAchievement;
                        }

                        Increment(achievement, numSteps, callback);
                    }
                    else
                    {
                        var error = new SA_Error(100, "Wasn't able to load achievement with id: " + achievementId);
                        callback.Invoke(new SA_Result(error));
                    }
                });
            }
        }
Esempio n. 26
0
        /// <summary>
        /// Method will retrive all contacts from user phone address book
        /// </summary>
        /// <param name="callback">address book contacts list will be delivered via this callback</param>
        /// <param name="checkForPermission">
        /// Will automatically check for READ_CONTACTS permissions.
        /// Please note That SupportV4 lib is required to prefrom the permission check
        /// </param>
        public static void Retrieve(Action <AN_ContactsResult> callback, bool checkForPermission = true)
        {
            if (Application.isEditor)
            {
                SA_Coroutine.WaitForSeconds(1, () => {
                    var result = new AN_ContactsResult();
                    callback.Invoke(result);
                });
                return;
            }

            AN_PermissionsUtility.TryToResolvePermission(AMM_ManifestPermission.READ_CONTACTS, (granted) => {
                if (granted)
                {
                    RetrieveNative(callback);
                }
                else
                {
                    var error          = new SA_Error(1, "READ_CONTACTS permission is missing");
                    var contactsResult = new AN_ContactsResult(error);
                    callback.Invoke(contactsResult);
                }
            });
        }
Esempio n. 27
0
 public UM_AchievementsLoadResult(SA_Error error) : base(error)
 {
 }
 public UM_MediaResult(SA_Error error) : base(error)
 {
 }
Esempio n. 29
0
 public AN_GoogleSignInResult(SA_Error error) : base(error)
 {
 }
Esempio n. 30
0
 public AN_ContactsResult(SA_Error error) : base(error)
 {
 }