Ejemplo n.º 1
0
        /// <summary>
        /// Requests privileges and starts MLContacts.
        /// </summary>
        private void StartAPI()
        {
            #if PLATFORM_LUMIN
            MLResult result = MLPrivilegesStarterKit.Start();
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: MLContactsBehavior failed starting MLPrivileges, disabling script. Reason: {0}", result);
                OnStartupComplete?.Invoke(false);
                enabled = false;
                return;
            }

            result = MLPrivilegesStarterKit.RequestPrivileges(MLPrivileges.Id.AddressBookRead, MLPrivileges.Id.AddressBookWrite);
            if (result.Result != MLResult.Code.PrivilegeGranted)
            {
                Debug.LogErrorFormat("Error: MLContactsBehavior failed requesting privileges, disabling script. Reason: {0}", result);
                OnStartupComplete?.Invoke(false);
                enabled = false;
                return;
            }

            MLPrivilegesStarterKit.Stop();

            result = MLContacts.Start();
            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: MLContactsBehavior failed starting MLContacts, disabling script. Reason: {0}", result);
                OnStartupComplete?.Invoke(false);
                enabled = false;
                return;
            }

            OnStartupComplete?.Invoke(true);
            #endif
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Start the API and register callbacks.
        /// </summary>
        private void StartupAPI()
        {
            MLResult result = MLContacts.Start();

            if (!result.IsOk)
            {
                Debug.LogErrorFormat("Error: ContactsExample failed starting MLContacts, disabling script. Reason: {0}", result);
                enabled = false;
                return;
            }

            Log("<color=green>API Started</color>");

            MLContacts.OnContactAdded    += HandleOnContactAdded;
            MLContacts.OnContactUpdated  += HandleOnContactUpdated;
            MLContacts.OnContactDeleted  += HandleOnContactDeleted;
            MLContacts.OnOperationFailed += HandleOnOperationFailed;

            LoadListPage();
        }