public override bool Initialise() { if (base.Initialise()) { TwitterSettings _twitterSettings = NPSettings.SocialNetworkSettings.TwitterSettings; cpnpTwitterInitTwitterKit(_twitterSettings.ConsumerKey, _twitterSettings.ConsumerSecret); return(true); } return(false); }
/// <summary> /// Initialise Twitter feature. /// </summary> /// <description> /// Make sure this is called before using twitter functions. Returns true on proper initialisation. /// </description> public virtual bool Initialise() { TwitterSettings _twitterSettings = NPSettings.SocialNetworkSettings.TwitterSettings; if (string.IsNullOrEmpty(_twitterSettings.ConsumerKey) || string.IsNullOrEmpty(_twitterSettings.ConsumerSecret)) { Console.LogError(Constants.kDebugTag, "[Twitter] Twitter initialize failed. Please configure Consumer Key and Consumer Secret in NPSettings."); return(false); } return(true); }
public override bool Initialise() { if (base.Initialise()) { TwitterSettings _twitterSettings = NPSettings.SocialNetworkSettings.TwitterSettings; Plugin.Call(Native.Methods.INITIALIZE, _twitterSettings.ConsumerKey, _twitterSettings.ConsumerSecret); return(true); } return(false); }
public override bool Initialise() { if (base.Initialise()) { // Get twitter settings info TwitterSettings _twitterSettings = NPSettings.SocialNetworkSettings.TwitterSettings; // Initalize twitter component initTwitterKit(_twitterSettings.ConsumerKey, _twitterSettings.ConsumerSecret); return(true); } return(false); }
// { // "Fabric": { // "APIKey": "{0}", // "Kits": [ // { // "KitInfo": { // "consumerKey": "", // "consumerSecret": "" // }, // "KitName": "Twitter" // } // ] // } // } private static void ModifyInfoPlist(string _buildPath) { ApplicationSettings.Features _supportedFeatures = NPSettings.Application.SupportedFeatures; if (!(_supportedFeatures.UsesTwitter || _supportedFeatures.UsesGameServices)) { return; } string _path2InfoPlist = Path.Combine(_buildPath, kInfoPlistFileRelativePath); string _path2InfoPlistBackupFile = Path.Combine(_buildPath, kInfoPlistBackupFileRelativePath); Plist _infoPlist = Plist.LoadPlistAtPath(_path2InfoPlist); // Create backup _infoPlist.Save(_path2InfoPlistBackupFile); // Adding twitter settings if (_supportedFeatures.UsesTwitter) { TwitterSettings _twitterSettings = NPSettings.SocialNetworkSettings.TwitterSettings; string _fabricJsonStr = string.Format(kFabricKitJsonStringFormat, _twitterSettings.ConsumerKey); IDictionary _fabricJsonDictionary = JSONUtility.FromJSON(_fabricJsonStr) as IDictionary; // Add fabric _infoPlist.AddValue(kFabricKitRootKey, _fabricJsonDictionary[kFabricKitRootKey] as IDictionary); } // Adding gamecenter settings if (_supportedFeatures.UsesGameServices) { IList _deviceCapablitiesList = _infoPlist.GetKeyPathValue(kDeviceCapablitiesKey) as IList; if (_deviceCapablitiesList == null) { _deviceCapablitiesList = new List <string>(); } if (!_deviceCapablitiesList.Contains("gamekit")) { _deviceCapablitiesList.Add("gamekit"); } _infoPlist.AddValue(kDeviceCapablitiesKey, _deviceCapablitiesList); } // Save _infoPlist.Save(_path2InfoPlist); }
/// <summary> /// Initialises the SDK with the credentials set in NPSettings. /// </summary> /// <returns><c>true</c> if SDK got initialised; otherwise, <c>false</c>.</returns> /// <remarks> /// \note You need to call this method, before using any features. /// This method requires that you have set up your consumerKey and consumerSecret in NPSettings. /// </remarks> public virtual bool Initialise() { TwitterSettings _twitterSettings = NPSettings.SocialNetworkSettings.TwitterSettings; if (string.IsNullOrEmpty(_twitterSettings.ConsumerKey) || string.IsNullOrEmpty(_twitterSettings.ConsumerSecret)) { DebugUtility.Logger.LogError(Constants.kDebugTag, "[Twitter] Twitter initialize failed. Please configure Consumer Key and Consumer Secret in NPSettings."); m_isInitialised = false; } else { m_isInitialised = true; } return(m_isInitialised); }
// { // "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 SocialNetworkSettings() { m_twitterSettings = new TwitterSettings(); }
// { // "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); }
public SocialNetworkSettings () { m_twitterSettings = new TwitterSettings(); }
// { // "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); }
// { // "Fabric": { // "APIKey": "{0}", // "Kits": [ // { // "KitInfo": { // "consumerKey": "", // "consumerSecret": "" // }, // "KitName": "Twitter" // } // ] // } // } private static void UpdateInfoPlist(string buildPath) { Debug.Log("[PostProcessBuild] : ModifyInfoPlist : " + buildPath); Dictionary <string, object> _newPermissionsDict = new Dictionary <string, object>(); // In this section, we add additional information required for proper functioning of used native features ApplicationSettings _applicationSettings = NPSettings.Application; Features _supportedFeatures = _applicationSettings.SupportedFeatures; #if USES_TWITTER 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 // In this section, we add extra flags required as per Apple guidelines if (_supportedFeatures.UsesNotificationService) { if (_supportedFeatures.NotificationService.usesRemoteNotification) { const string _kUIBackgroundModesKey = "UIBackgroundModes"; IList _backgroundModesList = AddUniqueValues(sourceList: (IList)infoPlist.GetKeyPathValue(_kUIBackgroundModesKey), values: "remote-notification"); _newPermissionsDict[_kUIBackgroundModesKey] = _backgroundModesList; } } if (_supportedFeatures.UsesGameServices) { const string _kDeviceCapablitiesKey = "UIRequiredDeviceCapabilities"; IList _deviceCapablitiesList = AddUniqueValues(sourceList: (IList)infoPlist.GetKeyPathValue(_kDeviceCapablitiesKey), values: "gamekit"); _newPermissionsDict[_kDeviceCapablitiesKey] = _deviceCapablitiesList; } if (_supportedFeatures.UsesSharing) { const string _kQuerySchemesKey = "LSApplicationQueriesSchemes"; IList _queriesSchemesList = AddUniqueValues(sourceList: (IList)infoPlist.GetKeyPathValue(_kQuerySchemesKey), values: new string[] { "whatsapp", "fb", "twitter" }); _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.ToString(); _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 (_supportedFeatures.UsesSharing) { _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); }