private void SingleFieldPromptDialogClosed(string _jsonStr)
        {
            Console.Log(Constants.kDebugTag, "[UI] Single field prompt was dismissed");

            if (OnSingleFieldPromptClosed != null)
            {
                IDictionary _dataDict = JSONUtility.FromJSON(_jsonStr) as IDictionary;
                string      _buttonPressed;
                string      _inputText;

                // Parse received data
                ParseSingleFieldPromptClosedData(_dataDict, out _buttonPressed, out _inputText);

                // Completion callback is triggered
                OnSingleFieldPromptClosed(_buttonPressed, _inputText);
            }
        }
        protected void TwitterLoginSuccess(string _sessionJsonStr)
        {
            // Resume unity player
            this.ResumeUnity();

            // Get session json object
            IDictionary    _sessionJsonDict = JSONUtility.FromJSON(_sessionJsonStr) as IDictionary;
            TwitterSession _session;

            // Parse received data
            ParseSessionData(_sessionJsonDict, out _session);
            Console.Log(Constants.kDebugTag, "[Twitter] Login success, Session=" + _session);

            // Invoke handler
            TwitterLoginFinished(_session, null);
            SetActiveSession(_session);
        }
//		{
//			"Fabric": {
//				"APIKey": "{0}",
//				"Kits": [
//				    {
//					"KitInfo": {
//						"consumerKey": "",
//						"consumerSecret": ""
//					},
//					"KitName": "Twitter"
//				    }
//				    ]
//			}
//		}

        private static void AppendFabricKitToInfoPlist(string _buildPath)
        {
            TwitterSettings _twitterSettings          = NPSettings.SocialNetworkSettings.TwitterSettings;
            string          _fabricJsonStr            = string.Format(kFabricKitJsonStringFormat, _twitterSettings.ConsumerKey);
            IDictionary     _fabricJsonDictionary     = JSONUtility.FromJSON(_fabricJsonStr) as IDictionary;
            string          _path2InfoPlist           = Path.Combine(_buildPath, kInfoPlistFileRelativePath);
            string          _path2InfoPlistBackupFile = Path.Combine(_buildPath, kInfoPlistBackupFileRelativePath);
            Plist           _infoPlist = Plist.LoadPlistAtPath(_path2InfoPlist);

            // Create backup
            _infoPlist.Save(_path2InfoPlistBackupFile);

            // Add fabric
            _infoPlist.AddValue(kFabricKitRootKey, _fabricJsonDictionary[kFabricKitRootKey] as IDictionary);

            // Save
            _infoPlist.Save(_path2InfoPlist);
        }
        public static CrossPlatformNotification CreateNotificationFromPayload(string _notificationPayload)
        {
            IDictionary _payloadDict = JSONUtility.FromJSON(_notificationPayload) as IDictionary;

            if (_payloadDict == null)
            {
                Console.LogError(Constants.kDebugTag, "[CrossPlatformNotification] Failed to create notification.");
                return(null);
            }

#if UNITY_ANDROID
            return(new AndroidNotificationPayload(_payloadDict));
#elif UNITY_IOS
            return(new iOSNotificationPayload(_payloadDict));
#else
            return(null);
#endif
        }
Example #5
0
        protected void PickImageFinished(string _responseJson)
        {
            IDictionary            _responseDict = JSONUtility.FromJSON(_responseJson) as IDictionary;
            string                 _imagePath;
            ePickImageFinishReason _finishReason;

            // Parse received data
            ParsePickImageFinishedData(_responseDict, out _imagePath, out _finishReason);

            if (string.IsNullOrEmpty(_imagePath) && _finishReason != ePickImageFinishReason.CANCELLED)
            {
                _finishReason = ePickImageFinishReason.FAILED;
                _imagePath    = null;
            }

            // Triggers event
            PickImageFinished(_imagePath, _finishReason);
        }
        private void DidFinishCommitingToCloud(string _dataStr)
        {
            IDictionary _dataDict    = (IDictionary)JSONUtility.FromJSON(_dataStr);
            string      _encodedData = _dataDict.GetIfAvailable <string>(kKeyForNewCloudData);
            bool        _isSuccess   = _dataDict.GetIfAvailable <bool>(kKeyForIsCommitSuccess);

            // If success, just make sure we write the new commited data to local disk.
            if (_isSuccess)
            {
                SetLocalStoreDiskData(_encodedData);
            }
            else             // Don't do anything.
            {
                Debug.LogError("Failed commiting to cloud!!!");
            }

            FinishedSync(_isSuccess);
        }
        private void LoginPromptDialogClosed(string _jsonStr)
        {
            Console.Log(Constants.kDebugTag, "[UI] Login prompt was dismissed");

            if (OnLoginPromptClosed != null)
            {
                IDictionary _jsonData = JSONUtility.FromJSON(_jsonStr) as IDictionary;
                string      _buttonPressed;
                string      _usernameText;
                string      _passwordText;

                // Parse received data
                ParseLoginPromptClosedData(_jsonData, out _buttonPressed, out _usernameText, out _passwordText);

                // Completion callback is triggered
                OnLoginPromptClosed(_buttonPressed, _usernameText, _passwordText);
            }
        }
Example #8
0
        private void AlertDialogClosed(string _jsonStr)
        {
            IDictionary _jsonData = JSONUtility.FromJSON(_jsonStr) as IDictionary;
            string      _buttonPressed;
            string      _callerTag;

            // Parse received data
            ParseAlertDialogDismissedData(_jsonData, out _buttonPressed, out _callerTag);
            Console.Log(Constants.kDebugTag, "[UI] Alert dialog closed, ButtonPressed=" + _buttonPressed);

            // Get callback
            AlertDialogCompletion _alertCompletionCallback = GetAlertDialogCallback(_callerTag);

            // Completion callback is triggered
            if (_alertCompletionCallback != null)
            {
                _alertCompletionCallback(_buttonPressed);
            }
        }
Example #9
0
        public Device(string DeviceName, DeviceParams Params = null)
        {
            var ParamsJson      = (Params == null) ? "{}" : JSONUtility.stringify(Params);
            var DeviceNameAscii = System.Text.ASCIIEncoding.ASCII.GetBytes(DeviceName + "\0");
            var ParamsJsonAscii = System.Text.ASCIIEncoding.ASCII.GetBytes(ParamsJson + "\0");
            var ErrorBuffer     = new byte[100];

            Instance = PopCameraDevice_CreateCameraDevice(DeviceNameAscii, ParamsJsonAscii, ErrorBuffer, ErrorBuffer.Length);
            var Error = GetString(ErrorBuffer);

            if (Instance.Value <= 0)
            {
                throw new System.Exception("Failed to create Camera device with name " + DeviceName + "; " + Error);
            }
            if (!String.IsNullOrEmpty(Error))
            {
                Debug.LogWarning("Created PopCameraDevice(" + Instance.Value + ") but error was not empty (length = " + Error.Length + ") " + Error);
            }
        }
        protected override void CloudKeyValueStoreDidChangeExternally(string _dataStr)
        {
            IDictionary _dataDict            = (IDictionary)JSONUtility.FromJSON(_dataStr);
            IList       _changedKeysJSONList = _dataDict.GetIfAvailable <IList>(kKeyForValueChangedKeys);
            eCloudDataStoreValueChangeReason _changeReason = ConvertToUnityFormatChangeReason(_dataDict.GetIfAvailable <NSUbiquitousKeyValueStoreChangeReason>(kKeyForChangeReason));

            // Copy keys to string array
            string[] _changedKeysArray = null;

            if (_changedKeysJSONList != null)
            {
                _changedKeysArray = new string[_changedKeysJSONList.Count];

                _changedKeysJSONList.CopyTo(_changedKeysArray, 0);
            }

            // Invoke handler
            CloudKeyValueStoreDidChangeExternally(_changeReason, _changedKeysArray);
        }
        private void DidReceiveNewCloudData(string _dataStr)
        {
            IDictionary _dataDict         = (IDictionary)JSONUtility.FromJSON(_dataStr);
            string      _encodedData      = _dataDict.GetIfAvailable <string>(kKeyForNewCloudData);
            string      _cloudAccountName = _dataDict.GetIfAvailable <string>(kKeyForCloudAccount);



            // Decode the data with Base64 and convert to Json IDict.
            if (!string.IsNullOrEmpty(_encodedData))
            {
                string _decodedData = _encodedData.FromBase64();

                DebugUtility.Logger.Log(Constants.kDebugTag, "[CloudServices] Received from Cloud : " + _decodedData);

                IDictionary _newCloudData = (IDictionary)JSONUtility.FromJSON(_decodedData);

                // Here compare the data with the one on local disk and trigger the ExternallyChagedEvent.
                CheckChangedKeyValueStoreDataAndRefresh(_newCloudData, _cloudAccountName);
            }
            else if (!m_isInitialised)
            {
                CloudKeyValueStoreDidInitialise(true);
            }

            //Set the flag to true
            m_isInitialised = true;


            if (IsLocalDirty())
            {
                SetLocalDirty(false);                 //We are setting to false and on failed commit to cloud we set it to true. If we don't set here, there could be chances for missing the flagstatus if set to false in callback on sucess of save.
                string _jsonString = m_dataStore.ToJSON();
                DebugUtility.Logger.Log(Constants.kDebugTag, "[CloudServices] Save To Cloud : " + _jsonString);
                Plugin.Call(Native.Methods.SAVE_CLOUD_DATA, _jsonString.ToBase64());
            }
            else
            {
                FinishedSync(true);
            }
        }
        private List <string> GetChangedKeys(IDictionary _localData, IDictionary _cloudData)
        {
            List <string> _changedKeys = new List <string>();

            // Merging and getting the total keys to reflect any removed keys.
            List <string> _totalKeys = MergeList(_localData.Keys, _cloudData.Keys);

            foreach (string _eachKey in _totalKeys)
            {
                object _eachCloudValue = _cloudData.GetIfAvailable <object>(_eachKey);
                object _eachLocalValue = _localData.GetIfAvailable <object>(_eachKey);

                // If the values don't match, we can tell the keys got changed.
                if (!JSONUtility.ToJSON(_eachLocalValue).Equals(JSONUtility.ToJSON(_eachCloudValue)))
                {
                    _changedKeys.Add(_eachKey);
                }
            }

            return(_changedKeys);
        }
Example #13
0
		private void BillingTransactionFinished (string _finishedTransactionsJsonStr)
		{
			IList _finishedTransactionJsonList				= JSONUtility.FromJSON(_finishedTransactionsJsonStr) as IList;
			int _finishedTransactionCount					= _finishedTransactionJsonList.Count;
			List<BillingTransaction> _finishedTransactions	= new List<BillingTransaction>(_finishedTransactionCount);

			for (int _iter = 0; _iter < _finishedTransactionCount; _iter++)
			{
				IDictionary _transactionDict	= _finishedTransactionJsonList[_iter] as IDictionary;
				BillingTransaction _transaction;

				// Parse received data
				ParseTransactionData(_transactionDict, out _transaction);

				// Add it to the list
				_finishedTransactions.Add(_transaction);
			}

			// Triggers event
			BillingTransactionFinished(_finishedTransactions);
		}
Example #14
0
		private void RequestForBillingProductsSuccess (string _regProductsJsonStr)
		{
			// Parse message
			IList _regProductsJsonList				= JSONUtility.FromJSON(_regProductsJsonStr) as IList;
			int _regProductsCount					= _regProductsJsonList.Count;
			List<BillingProduct> _regProductsList	= new List<BillingProduct>(_regProductsCount);
			
			for (int _iter = 0; _iter < _regProductsCount; _iter++)
			{
				IDictionary _registeredProductDict	= _regProductsJsonList[_iter] as IDictionary;
				BillingProduct _registeredProduct;

				// Parse received data
				ParseProductData(_registeredProductDict, out _registeredProduct);

				// Add it to the list
				_regProductsList.Add(_registeredProduct);
			}

			// Triggers event
			RequestForBillingProductsSuccess(_regProductsList);
		}
Example #15
0
        private void ABReadContactsFinished(string _contactsJsonStr)
        {
            IList _contactsJsonList = JSONUtility.FromJSON(_contactsJsonStr) as IList;
            int   _count            = _contactsJsonList.Count;

            AddressBookContact[] _contactsList = new AddressBookContact[_count];

            for (int _iter = 0; _iter < _count; _iter++)
            {
                AddressBookContact _contact;
                IDictionary        _contactInfoDict = _contactsJsonList[_iter] as IDictionary;

                // Parse native data
                ParseContactData(_contactInfoDict, out _contact);

                // Add parsed object
                _contactsList[_iter] = _contact;
            }

            // Triggers event
            ABReadContactsFinished(_contactsList);
        }
        protected override void ParseAppLaunchInfo(string _launchData, out CrossPlatformNotification _launchLocalNotification, out CrossPlatformNotification _launchRemoteNotification)
        {
            Dictionary <string, object> _launchDataDict = JSONUtility.FromJSON(_launchData) as Dictionary <string, object>;
            object _payloadDict = null;

            // Launched with local notification
            if (_launchDataDict.TryGetValue(kAppLaunchLocalNotification, out _payloadDict))
            {
                _launchLocalNotification  = new iOSNotificationPayload((IDictionary)_payloadDict);
                _launchRemoteNotification = null;
            }
            // Launched with remote notification
            else if (_launchDataDict.TryGetValue(kAppLaunchRemoteNotification, out _payloadDict))
            {
                _launchLocalNotification  = null;
                _launchRemoteNotification = new iOSNotificationPayload((IDictionary)_payloadDict);
            }
            // Normal launch
            else
            {
                _launchLocalNotification  = null;
                _launchRemoteNotification = null;
            }
        }
        public void Initialise()
        {
            string _localNotificationJSONStr  = EditorPrefs.GetString(kDidStartWithLocalNotification, string.Empty);
            string _remoteNotificationJSONStr = EditorPrefs.GetString(kDidStartWithRemoteNotification, string.Empty);
            CrossPlatformNotification _launchLocalNotification  = null;
            CrossPlatformNotification _launchRemoteNotification = null;

            // Get launch local notification
            if (!string.IsNullOrEmpty(_localNotificationJSONStr))
            {
                _launchLocalNotification = new CrossPlatformNotification(JSONUtility.FromJSON(_localNotificationJSONStr) as IDictionary);
            }
            else if (!string.IsNullOrEmpty(_remoteNotificationJSONStr))
            {
                _launchRemoteNotification = new CrossPlatformNotification(JSONUtility.FromJSON(_remoteNotificationJSONStr) as IDictionary);
            }

            // Send app launch info
            NPBinding.NotificationService.InvokeMethod(kDidReceiveAppLaunchInfoEvent, new CrossPlatformNotification[] { _launchLocalNotification, _launchRemoteNotification }, new System.Type[] { typeof(CrossPlatformNotification), typeof(CrossPlatformNotification) });

            // Remove saved values
            EditorPrefs.DeleteKey(kDidStartWithLocalNotification);
            EditorPrefs.DeleteKey(kDidStartWithRemoteNotification);
        }
Example #18
0
//		{
//			"Fabric": {
//				"APIKey": "{0}",
//				"Kits": [
//				    {
//					"KitInfo": {
//						"consumerKey": "",
//						"consumerSecret": ""
//					},
//					"KitName": "Twitter"
//				    }
//				    ]
//			}
//		}

        private static void ModifyInfoPlist(string _buildPath)
        {
            Debug.Log("[PostProcessBuild] : ModifyInfoPlist : " + _buildPath);

            ApplicationSettings _applicationSettings = NPSettings.Application;

            ApplicationSettings.Features _supportedFeatures  = NPSettings.Application.SupportedFeatures;
            Dictionary <string, object>  _newPermissionsDict = new Dictionary <string, object>();

#if USES_TWITTER
            // Add twitter info
            if (_supportedFeatures.UsesTwitter)
            {
                const string _kFabricKitRootKey = "Fabric";

                TwitterSettings _twitterSettings = NPSettings.SocialNetworkSettings.TwitterSettings;
                string          _fabricJsonStr   = string.Format(kFabricKitJsonStringFormat, _twitterSettings.ConsumerKey);

                IDictionary _fabricJsonDictionary = (IDictionary)JSONUtility.FromJSON(_fabricJsonStr);
                _newPermissionsDict[_kFabricKitRootKey] = _fabricJsonDictionary[_kFabricKitRootKey];
            }
#endif

            // Add permissions
            if (_supportedFeatures.UsesNotificationService)
            {
#if !UNITY_4
                if (_supportedFeatures.NotificationService.usesRemoteNotification)
                {
                    const string _kUIBackgroundModesKey      = "UIBackgroundModes";
                    const string _kRemoteNotificationProcess = "remote-notification";

                    IList _backgroundModesList = (IList)infoPlist.GetKeyPathValue(_kUIBackgroundModesKey);
                    if (_backgroundModesList == null)
                    {
                        _backgroundModesList = new List <string>();
                    }

                    if (!_backgroundModesList.Contains(_kRemoteNotificationProcess))
                    {
                        _backgroundModesList.Add(_kRemoteNotificationProcess);
                    }

                    _newPermissionsDict[_kUIBackgroundModesKey] = _backgroundModesList;
                }
#endif
            }

            if (_supportedFeatures.UsesGameServices)
            {
                const string _kDeviceCapablitiesKey = "UIRequiredDeviceCapabilities";
                const string _kGameKitKey           = "gamekit";

                IList _deviceCapablitiesList = (IList)infoPlist.GetKeyPathValue(_kDeviceCapablitiesKey);
                if (_deviceCapablitiesList == null)
                {
                    _deviceCapablitiesList = new List <string>();
                }

                if (!_deviceCapablitiesList.Contains(_kGameKitKey))
                {
                    _deviceCapablitiesList.Add(_kGameKitKey);
                }

                _newPermissionsDict[_kDeviceCapablitiesKey] = _deviceCapablitiesList;
            }

            if (_supportedFeatures.UsesSharing)
            {
                const string _kQuerySchemesKey = "LSApplicationQueriesSchemes";
                const string _kWhatsAppKey     = "whatsapp";

                IList _queriesSchemesList = (IList)infoPlist.GetKeyPathValue(_kQuerySchemesKey);
                if (_queriesSchemesList == null)
                {
                    _queriesSchemesList = new List <string>();
                }

                if (!_queriesSchemesList.Contains(_kWhatsAppKey))
                {
                    _queriesSchemesList.Add(_kWhatsAppKey);
                }

                _newPermissionsDict[_kQuerySchemesKey] = _queriesSchemesList;
            }

            if (_supportedFeatures.UsesNetworkConnectivity || _supportedFeatures.UsesWebView)
            {
                const string _kATSKey            = "NSAppTransportSecurity";
                const string _karbitraryLoadsKey = "NSAllowsArbitraryLoads";

                IDictionary _transportSecurityDict = (IDictionary)infoPlist.GetKeyPathValue(_kATSKey);
                if (_transportSecurityDict == null)
                {
                    _transportSecurityDict = new Dictionary <string, object>();
                }

                _transportSecurityDict[_karbitraryLoadsKey] = true;
                _newPermissionsDict[_kATSKey] = _transportSecurityDict;
            }

            // Add privacy info
            const string _kPermissionContacts           = "NSContactsUsageDescription";
            const string _kPermissionCamera             = "NSCameraUsageDescription";
            const string _kPermissionPhotoLibrary       = "NSPhotoLibraryUsageDescription";
            const string _kPermissionModifyPhotoLibrary = "NSPhotoLibraryAddUsageDescription";

            if (_supportedFeatures.UsesAddressBook)
            {
                _newPermissionsDict[_kPermissionContacts] = _applicationSettings.IOS.AddressBookUsagePermissionDescription;
            }

            if (_supportedFeatures.UsesMediaLibrary)
            {
                if (_supportedFeatures.MediaLibrary.usesCamera)
                {
                    _newPermissionsDict[_kPermissionCamera] = _applicationSettings.IOS.CameraUsagePermissionDescription;
                }

                if (_supportedFeatures.MediaLibrary.usesPhotoAlbum)
                {
                    _newPermissionsDict [_kPermissionPhotoLibrary]       = _applicationSettings.IOS.PhotoAlbumUsagePermissionDescription;
                    _newPermissionsDict [_kPermissionModifyPhotoLibrary] = _applicationSettings.IOS.PhotoAlbumModifyUsagePermissionDescription;
                }
            }

            if (_newPermissionsDict.Count == 0)
            {
                return;
            }

            // Create a backup of old plist
            string _infoPlistBackupSavePath = GetInfoPlistBackupFilePath(_buildPath);
            infoPlist.Save(_infoPlistBackupSavePath);

            // Save the plist with new permissions
            foreach (string _key in _newPermissionsDict.Keys)
            {
                infoPlist.AddValue(_key, _newPermissionsDict[_key]);
            }

            string _infoPlistSavePath = GetInfoPlistFilePath(_buildPath);
            infoPlist.Save(_infoPlistSavePath);
        }
Example #19
0
        public override IDictionary GetDictionary(string _key)
        {
            string _JSONString = GetValue <string>(_key);

            return((_JSONString == null) ? null : (IDictionary)JSONUtility.FromJSON(_JSONString));
        }
Example #20
0
        public override IList GetList(string _key)
        {
            string _JSONString = GetValue <string>(_key);

            return((_JSONString == null) ? null : (IList)JSONUtility.FromJSON(_JSONString));
        }
        public void Initialise()
        {
            string _localNotificationPayload  = EditorPrefs.GetString(kDidStartWithLocalNotification, string.Empty);
            string _remoteNotificationPayload = EditorPrefs.GetString(kDidStartWithRemoteNotification, string.Empty);

            // Get launch local notification
            if (!string.IsNullOrEmpty(_localNotificationPayload))
            {
                CrossPlatformNotification _notification = new CrossPlatformNotification(JSONUtility.FromJSON(_localNotificationPayload) as IDictionary);

                // Send event
                SendLocalNotification(_notification, true);
            }
            else if (!string.IsNullOrEmpty(_remoteNotificationPayload))
            {
                CrossPlatformNotification _notification = new CrossPlatformNotification(JSONUtility.FromJSON(_remoteNotificationPayload) as IDictionary);

                // Send event
                SendRemoteNotification(_notification, true);
            }

            // Remove saved values
            EditorPrefs.DeleteKey(kDidStartWithLocalNotification);
            EditorPrefs.DeleteKey(kDidStartWithRemoteNotification);
        }
Example #22
0
//		{
//			"Fabric": {
//				"APIKey": "{0}",
//				"Kits": [
//				    {
//					"KitInfo": {
//						"consumerKey": "",
//						"consumerSecret": ""
//					},
//					"KitName": "Twitter"
//				    }
//				    ]
//			}
//		}

        private static void ModifyInfoPlist(string _buildPath)
        {
            ApplicationSettings.Features _supportedFeatures  = NPSettings.Application.SupportedFeatures;
            Dictionary <string, object>  _newPermissionsDict = new Dictionary <string, object>();

            // Add twitter info
#if USES_TWITTER
            {
                const string    _kFabricKitRootKey    = "Fabric";
                TwitterSettings _twitterSettings      = NPSettings.SocialNetworkSettings.TwitterSettings;
                string          _fabricJsonStr        = string.Format(kFabricKitJsonStringFormat, _twitterSettings.ConsumerKey);
                IDictionary     _fabricJsonDictionary = (IDictionary)JSONUtility.FromJSON(_fabricJsonStr);

                // Add fabric
                _newPermissionsDict[_kFabricKitRootKey] = _fabricJsonDictionary[_kFabricKitRootKey];
            }
#endif

            // Add background process details
#if USES_NOTIFICATION_SERVICE && USES_ONE_SIGNAL
            const string _kUIBackgroundModesKey = "UIBackgroundModes";
            IList        _backgroundModesList   = (IList)infoPlist.GetKeyPathValue(_kUIBackgroundModesKey);

            if (_backgroundModesList == null)
            {
                _backgroundModesList = new List <string>();
            }

            const string _kRemoteNotificationProcess = "remote-notification";

            if (!_backgroundModesList.Contains(_kRemoteNotificationProcess))
            {
                _backgroundModesList.Add(_kRemoteNotificationProcess);
            }

            _newPermissionsDict[_kUIBackgroundModesKey] = _backgroundModesList;
#endif

            // Device capablities addition
            if (_supportedFeatures.UsesGameServices)
            {
                const string _kDeviceCapablitiesKey = "UIRequiredDeviceCapabilities";
                const string _kGameKitKey           = "gamekit";
                IList        _deviceCapablitiesList = (IList)infoPlist.GetKeyPathValue(_kDeviceCapablitiesKey);

                if (_deviceCapablitiesList == null)
                {
                    _deviceCapablitiesList = new List <string>();
                }

                if (!_deviceCapablitiesList.Contains(_kGameKitKey))
                {
                    _deviceCapablitiesList.Add(_kGameKitKey);
                }

                _newPermissionsDict[_kDeviceCapablitiesKey] = _deviceCapablitiesList;
            }

            // Query scheme related key inclusion
            if (_supportedFeatures.UsesSharing)
            {
                const string _kQuerySchemesKey   = "LSApplicationQueriesSchemes";
                const string _kWhatsAppKey       = "whatsapp";
                IList        _queriesSchemesList = (IList)infoPlist.GetKeyPathValue(_kQuerySchemesKey);

                if (_queriesSchemesList == null)
                {
                    _queriesSchemesList = new List <string>();
                }

                if (!_queriesSchemesList.Contains(_kWhatsAppKey))
                {
                    _queriesSchemesList.Add(_kWhatsAppKey);
                }

                _newPermissionsDict[_kQuerySchemesKey] = _queriesSchemesList;
            }

            // Apple transport security
            if (_supportedFeatures.UsesNetworkConnectivity || _supportedFeatures.UsesWebView)
            {
                const string _kATSKey               = "NSAppTransportSecurity";
                const string _karbitraryLoadsKey    = "NSAllowsArbitraryLoads";
                IDictionary  _transportSecurityDict = (IDictionary)infoPlist.GetKeyPathValue(_kATSKey);

                if (_transportSecurityDict == null)
                {
                    _transportSecurityDict = new Dictionary <string, object>();
                }

                _transportSecurityDict[_karbitraryLoadsKey] = true;
                _newPermissionsDict[_kATSKey] = _transportSecurityDict;
            }

            if (_newPermissionsDict.Count == 0)
            {
                return;
            }

            // First create a backup of old data
            string _infoPlistBackupSavePath = GetInfoPlistBackupFilePath(_buildPath);

            infoPlist.Save(_infoPlistBackupSavePath);

            // Now add new permissions
            foreach (string _key in _newPermissionsDict.Keys)
            {
                infoPlist.AddValue(_key, _newPermissionsDict[_key]);
            }

            // Save these changes
            string _infoPlistSavePath = GetInfoPlistFilePath(_buildPath);

            infoPlist.Save(_infoPlistSavePath);
        }
Example #23
0
        private static void     GenerateXcodeModFiles()
        {
            string _xcodeModDataCollectionText = File.ReadAllText(kRelativePathXcodeModDataCollectionFile);

            if (_xcodeModDataCollectionText == null)
            {
                return;
            }

            IDictionary _xcodeModDataCollectionDict = JSONUtility.FromJSON(_xcodeModDataCollectionText) as IDictionary;

            ApplicationSettings.Features      _supportedFeatures      = NPSettings.Application.SupportedFeatures;
            ApplicationSettings.AddonServices _supportedAddonServices = NPSettings.Application.SupportedAddonServices;

            // Create mod file related to supported features
            ExtractAndSerializeXcodeModInfo(_xcodeModDataCollectionDict, kModKeyCommon, kRelativePathIOSNativeCodeFolder);

            if (_supportedFeatures.UsesAddressBook)
            {
                ExtractAndSerializeXcodeModInfo(_xcodeModDataCollectionDict, kModKeyAddressBook, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesBilling)
            {
                ExtractAndSerializeXcodeModInfo(_xcodeModDataCollectionDict, kModKeyBilling, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesCloudServices)
            {
                ExtractAndSerializeXcodeModInfo(_xcodeModDataCollectionDict, kModKeyCloudServices, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesGameServices)
            {
                ExtractAndSerializeXcodeModInfo(_xcodeModDataCollectionDict, kModKeyGameServices, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesMediaLibrary)
            {
                ExtractAndSerializeXcodeModInfo(_xcodeModDataCollectionDict, kModKeyMediaLibrary, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesNetworkConnectivity)
            {
                ExtractAndSerializeXcodeModInfo(_xcodeModDataCollectionDict, kModKeyNetworkConnectivity, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesNotificationService)
            {
                ExtractAndSerializeXcodeModInfo(_xcodeModDataCollectionDict, kModKeyNotification, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesSharing)
            {
                ExtractAndSerializeXcodeModInfo(_xcodeModDataCollectionDict, kModKeySharing, kRelativePathIOSNativeCodeFolder);
            }

            if (_supportedFeatures.UsesTwitter)
            {
                ExtractAndSerializeXcodeModInfo(_xcodeModDataCollectionDict, kModKeyTwitter, kRelativePathIOSNativeCodeFolder);
                ExtractAndSerializeXcodeModInfo(_xcodeModDataCollectionDict, kModKeyTwitterSDK, kRelativePathNativePluginsSDKFolder);
            }

            if (_supportedFeatures.UsesWebView)
            {
                ExtractAndSerializeXcodeModInfo(_xcodeModDataCollectionDict, kModKeyWebView, kRelativePathIOSNativeCodeFolder);
            }

            // Create mod file related to supported addon features
            if (_supportedAddonServices.UsesSoomlaGrow)
            {
                ExtractAndSerializeXcodeModInfo(_xcodeModDataCollectionDict, kModKeySoomlaGrow, kRelativePathIOSNativeCodeFolder);
            }
        }
        private static void WriteValuesFile()
        {
            // Settings
            XmlWriterSettings _settings = new XmlWriterSettings();

            _settings.Encoding         = new System.Text.UTF8Encoding(true);
            _settings.ConformanceLevel = ConformanceLevel.Document;
            _settings.Indent           = true;


            string targetPath   = kGoogleServicesGeneratedXMLFilePath;
            string templatePath = Constants.kPluginAssetsPath + "/Plugins/Features/NotificationService/Editor/google-services.template";

            Directory.CreateDirectory(Path.GetDirectoryName(targetPath));

            // Replace strings in Template
            string templateContent = FileOperations.ReadAllText(templatePath);

            if (IsGoogleServicesJsonFileAvailable())
            {
                string googleServicesJsonContent = FileOperations.ReadAllText(kGoogleServicesJsonPath);

                IDictionary googleServicesJsonContentMap = (IDictionary)JSONUtility.FromJSON(googleServicesJsonContent);

                IDictionary projectInfo         = googleServicesJsonContentMap.GetIfAvailable <IDictionary>("project_info");
                string      firebaseDatabaseURL = projectInfo["firebase_url"] as string;
                string      projectNumber       = projectInfo["project_number"] as string;
                string      storageBucket       = projectInfo["storage_bucket"] as string;
                string      projectID           = projectInfo["project_id"] as string;

                templateContent = templateContent.Replace("FIREBASE_DATABASE_URL", firebaseDatabaseURL);
                templateContent = templateContent.Replace("GCM_DEFAULT_SENDER_ID", projectNumber);
                templateContent = templateContent.Replace("GOOGLE_STORAGE_BUCKET", storageBucket);
                templateContent = templateContent.Replace("PROJECT_ID", projectID);

                IList clientList = googleServicesJsonContentMap.GetIfAvailable <IList>("client");

                if (clientList != null && clientList.Count > 0)
                {
                    foreach (IDictionary eachClient in clientList)
                    {
                        IDictionary clientInfo        = eachClient.GetIfAvailable <IDictionary>("client_info");
                        IDictionary androidClientInfo = clientInfo.GetIfAvailable <IDictionary>("android_client_info");

                        string clientPackageName = androidClientInfo.GetIfAvailable <string>("package_name");

                        if (clientPackageName.Equals(VoxelBusters.Utility.PlayerSettings.GetBundleIdentifier()))
                        {
                            IDictionary oauthClient = (IDictionary)(eachClient.GetIfAvailable <IList>("oauth_client")[0]);
                            IDictionary apiKey      = (IDictionary)(eachClient.GetIfAvailable <IList>("api_key")[0]);

                            templateContent = templateContent.Replace("GOOGLE_APP_ID", clientInfo["mobilesdk_app_id"] as string);
                            templateContent = templateContent.Replace("GOOGLE_API_KEY", apiKey["current_key"] as string);
                            templateContent = templateContent.Replace("GOOGLE_CRASH_REPORTING_API_KEY", apiKey["current_key"] as string);
                            templateContent = templateContent.Replace("DEFAULT_WEB_CLIENT_ID", oauthClient["client_id"] as string);
                            break;
                        }
                    }
                }
                FileOperations.WriteAllText(targetPath, templateContent);
            }
        }
Example #25
0
 private void loadPlayerTankSchematic(JObject root)
 {
     TankSchematic = JSONUtility.LoadTankSchematic(root.Value <JObject>("Tank"));
 }
        private void SignOutFinished(string _dataStr)
        {
            IDictionary _dataDict = (IDictionary)JSONUtility.FromJSON(_dataStr);

            SignOutFinished(_dataDict);
        }
        public override IDictionary GetDictionary(string _key)
        {
            string _JSONString = EditorPrefs.GetString(_key, null);

            return((_JSONString == null) ? null : (IDictionary)JSONUtility.FromJSON(_JSONString));
        }
        public override IList GetList(string _key)
        {
            string _JSONString = EditorPrefs.GetString(_key, null);

            return((_JSONString == null) ? null : (IList)JSONUtility.FromJSON(_JSONString));
        }
        public override IDictionary GetDictionary(string _key)
        {
            string _JSONString = cpnpCloudServicesGetDictionary(_key);

            return((_JSONString == null) ? null : (IDictionary)JSONUtility.FromJSON(_JSONString));
        }
        public override IList GetList(string _key)
        {
            string _JSONString = cpnpCloudServicesGetList(_key);

            return((_JSONString == null) ? null : (IList)JSONUtility.FromJSON(_JSONString));
        }