Example #1
0
        public static void DownloadiOSFramework(Action onSuccess = null, Action <string> onFailure = null)
        {
            IOSDownloadInProgress = true;

            var pluginFolderPath = Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathiOS);

            RemoveOldVersions(pluginFolderPath);

            var downloadFrameworkRequest = DownloadFrameworkRequest.Create(string.Format(DownloadUrliOS, BuildConfig.UnitySdkVersion),
                                                                           pluginFolderPath,
                                                                           Path.Combine(pluginFolderPath, IOSArchiveName));

            downloadFrameworkRequest.Start(() =>
            {
                IOSDownloadInProgress = false;
                UnzipFramework(Path.Combine(pluginFolderPath, IOSArchiveName), pluginFolderPath);
                AddFrameworksToAssets(new[]
                {
                    Path.Combine(DestinationFolderPathiOS, IOSFrameworkName_Core),
                    Path.Combine(DestinationFolderPathiOS, IOSFrameworkName_UI)
                });
                if (onSuccess != null)
                {
                    onSuccess();
                }
            }, error =>
            {
                IOSDownloadInProgress = false;
                Debug.LogError(string.Format("GetSocial: Failed to download native iOS SDK, error: {0}", error));
                if (onFailure != null)
                {
                    onFailure(error);
                }
            }, IsInBatchMode());
        }
Example #2
0
        public static void SetGetSocialUiEnabled(bool enabled)
        {
            var androidCoreLib = new string[0];
            var androidUiLib   = new string[0];

            var iosCoreLib = new string[0];
            var iosUiLib   = new string[0];

            if (Directory.Exists(Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathAndroid)) && !AndroidDownloadInProgress)
            {
                androidCoreLib = AssetDatabase.FindAssets(AndroidFrameworkName_Core, new [] { Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathAndroid) });
                androidUiLib   = AssetDatabase.FindAssets(AndroidFrameworkName_UI, new [] { Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathAndroid) });
            }

            if (Directory.Exists(Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathiOS)) && !IOSDownloadInProgress)
            {
                iosCoreLib = AssetDatabase.FindAssets(IOSFrameworkName_Core, new[] { Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathiOS) });
                iosUiLib   = AssetDatabase.FindAssets(IOSFrameworkName_UI, new[] { Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathiOS) });
            }

            UpdatePlatformState(iosCoreLib, BuildTarget.iOS, true);
            UpdatePlatformState(iosUiLib, BuildTarget.iOS, enabled);
            UpdatePlatformState(androidCoreLib, BuildTarget.Android, true);
            UpdatePlatformState(androidUiLib, BuildTarget.Android, enabled);
        }
        static void EmbedFrameworks(PBXProject project, string target)
        {
            const string coreFrameworkName      = "GetSocial.framework";
            const string uiFrameworkName        = "GetSocialUI.framework";
            const string extensionFrameworkName = "GetSocialExtension.framework";

            var frameworksPath =
                GetSocialSettings.GetPluginPath().Substring(GetSocialSettings.GetPluginPath().IndexOf("/") + 1);

            var defaultLocationInProj          = "Frameworks/" + frameworksPath + "/Plugins/iOS/";
            var relativeCoreFrameworkPath      = defaultLocationInProj + coreFrameworkName;
            var relativeExtensionFrameworkPath = defaultLocationInProj + extensionFrameworkName;
            var relativeUiFrameworkPath        = defaultLocationInProj + uiFrameworkName;

            project.AddDynamicFrameworkToProject(target, relativeCoreFrameworkPath);
            project.AddDynamicFrameworkToProject(target, relativeExtensionFrameworkPath);
            if (GetSocialSettings.UseGetSocialUi)
            {
                project.AddDynamicFrameworkToProject(target, relativeUiFrameworkPath);
            }
            else
            {
                project.RemoveDynamicFramework(target, relativeUiFrameworkPath);
            }

#if !UNITY_CLOUD_BUILD
            Debug.Log("GetSocial: GetSocial Dynamic Frameworks added to Embedded binaries.");
#endif
        }
Example #4
0
 private static void AddFrameworksToAssets(string[] filePath)
 {
     foreach (var path in filePath)
     {
         AssetDatabase.ImportAsset(Path.Combine(GetSocialSettings.GetPluginPath(), path), ImportAssetOptions.ForceUpdate);
     }
 }
        void OnEnable()
        {
            _image = new Texture2D(1, 1);
            var imagePath = Path.Combine(GetSocialSettings.GetPluginPath(), "Editor/GUI/" + Styles.CurrentSkin.ImageName);

            _image.LoadImage(System.IO.File.ReadAllBytes(imagePath));
            _image.Apply();
        }
Example #6
0
        public static void MarkIOSFrameworks()
        {
            var iOSFrameworksDir = Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathiOS);

            foreach (var framework in IOSFrameworks)
            {
                UpdatePlatformState(Path.Combine(iOSFrameworksDir, framework), BuildTarget.iOS, true);
            }
        }
Example #7
0
        private static void MarkIosFiles()
        {
            var coreDir = Path.Combine(GetSocialSettings.GetPluginPath(), "Editor/iOS/GetSocial");
            var uiDir   = Path.Combine(GetSocialSettings.GetPluginPath(), "Editor/iOS/GetSocialUI");

            ForEachIn(coreDir, path => UpdatePlatformState(path, BuildTarget.iOS, true));
            ForEachIn(uiDir, path => UpdatePlatformState(path, BuildTarget.iOS, true));
            MarkIOSFrameworks();
        }
        public static void DownloadiOSFramework(Action onSuccess = null, Action <string> onFailure = null)
        {
            IOSDownloadInProgress = true;

            var pluginFolderPath = Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathiOS);

            RemoveOldVersions(pluginFolderPath);

            var downloadFrameworkRequest = DownloadFrameworkRequest.Create(string.Format(DownloadUrliOS, BuildConfig.UnitySdkVersion),
                                                                           pluginFolderPath,
                                                                           Path.Combine(pluginFolderPath, IOSArchiveName));

            downloadFrameworkRequest.Start(() =>
            {
                IOSDownloadInProgress = false;
                IOSDownloadProgress   = 0;
                if (UnzipFramework(Path.Combine(pluginFolderPath, IOSArchiveName), pluginFolderPath))
                {
                    AddFrameworksToAssets(new[]
                    {
                        Path.Combine(DestinationFolderPathiOS, IOSFrameworkName_Core),
                        Path.Combine(DestinationFolderPathiOS, IOSFrameworkName_Extension),
                        Path.Combine(DestinationFolderPathiOS, IOSFrameworkName_UI)
                    });

                    foreach (var framework in IOSFrameworks)
                    {
                        UpdatePlatformState(Path.Combine(pluginFolderPath, framework), BuildTarget.iOS, true);
                    }
                    if (onSuccess != null)
                    {
                        onSuccess();
                    }
                }
                else
                {
                    var error = "unzip command failed";
                    Debug.LogError(string.Format("GetSocial: Failed to download native iOS SDK, error: {0}", error));
                    if (onFailure != null)
                    {
                        onFailure(error);
                    }
                }
            }, progress =>
            {
                IOSDownloadProgress = progress;
            }, error =>
            {
                IOSDownloadInProgress = false;
                Debug.LogError(string.Format("GetSocial: Failed to download native iOS SDK, error: {0}", error));
                if (onFailure != null)
                {
                    onFailure(error);
                }
            }, IsInBatchMode());
        }
        private void DrawWebView()
        {
            if (_webView.Hook(this))
            {
                var pagePath = Path.Combine(GetSocialSettings.GetAbsolutePluginPath(), PageToLoadPath);
                _webView.LoadFile(pagePath);
            }

            _webView.OnGUI(new Rect(0, 0, position.width, position.height));
        }
Example #10
0
        private static void MarkIosFiles()
        {
            var coreDir = Path.Combine(GetSocialSettings.GetPluginPath(), "Editor/iOS/GetSocial");
            var uiDir   = Path.Combine(GetSocialSettings.GetPluginPath(), "Editor/iOS/GetSocialUI");

            ForEachIn(coreDir, path => UpdatePlatformState(new [] { path }, BuildTarget.iOS, true));
            ForEachIn(uiDir, path => UpdatePlatformState(new [] { path }, BuildTarget.iOS, true));
            var coreFrameworkPath = AssetDatabase.AssetPathToGUID(Path.Combine(GetSocialSettings.GetPluginPath(), "Plugins/iOS/GetSocial.framework"));
            var uiFrameworkPath   = AssetDatabase.AssetPathToGUID(Path.Combine(GetSocialSettings.GetPluginPath(), "Plugins/iOS/GetSocialUI.framework"));

            UpdatePlatformState(new [] { coreFrameworkPath }, BuildTarget.iOS, true);
            UpdatePlatformState(new [] { uiFrameworkPath }, BuildTarget.iOS, true);
        }
Example #11
0
 public void OnPreprocessBuild(BuildReport report)
 {
     Debug.Log("GetSocialPreprocess.OnPreprocessBuild for target " + report.summary.platform + " at path " + report.summary.outputPath);
     if (report.summary.platform == BuildTarget.iOS)
     {
         FileHelper.MarkIOSFrameworks();
     }
     if (report.summary.platform == BuildTarget.Android)
     {
         AndroidManifestHelper.RemoveSdk6Configs();
     }
     GetSocialSettings.UpdateConfigsFile();
 }
        static void AddStripFrameworksScriptBuildPhase(PBXProject project, string projectPath, string target)
        {
            // remove previous script versions
            project.RemoveShellScript(target, "GetSocial.framework/strip_frameworks.sh");

            const string script         = "bash ./strip_frameworks.sh";
            var          pluginDir      = GetSocialSettings.GetPluginPath();
            var          scriptFilePath = Path.Combine(pluginDir, "Editor");

            scriptFilePath = Path.Combine(scriptFilePath, "iOS");
            scriptFilePath = Path.Combine(scriptFilePath, "Postprocessing");
            scriptFilePath = Path.Combine(scriptFilePath, "strip_frameworks.sh");
            File.Copy(scriptFilePath, Path.Combine(projectPath, "strip_frameworks.sh"), true);
            project.AddShellScript(target, script);
        }
        private void EnsureManifestExists(string manifestPath)
        {
            if (!File.Exists(manifestPath))
            {
                var backupManifestPath = Path.Combine(GetSocialSettings.GetPluginPath(), "Editor/Android/BackupManifest/AndroidManifest.xml");

                var manifestDirectoryPath = Path.GetDirectoryName(manifestPath);
                if (!Directory.Exists(manifestDirectoryPath))
                {
                    Directory.CreateDirectory(manifestDirectoryPath);
                }

                File.Copy(backupManifestPath, manifestPath);
            }
        }
        internal static void MarkIosFiles()
        {
            var coreDir = Path.Combine(GetSocialSettings.GetPluginPath(), "Editor/iOS/GetSocial");
            var uiDir   = Path.Combine(GetSocialSettings.GetPluginPath(), "Editor/iOS/GetSocialUI");

            ForEachIn(coreDir, path => UpdatePlatformState(path, BuildTarget.iOS, true));
            ForEachIn(uiDir, path => UpdatePlatformState(path, BuildTarget.iOS, true));

            var iOSFrameworksDir = Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathiOS);

            foreach (var framework in IOSFrameworks)
            {
                UpdatePlatformState(Path.Combine(iOSFrameworksDir, framework), BuildTarget.iOS, true);
            }
        }
        public static void SetGetSocialUiEnabled(bool enabled)
        {
            if (Directory.Exists(Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathAndroid)) && !AndroidDownloadInProgress)
            {
                var path = Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathAndroid);

                UpdatePlatformState(Path.Combine(path, AndroidFrameworkName_UI), BuildTarget.Android, enabled);
            }

            if (Directory.Exists(Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathiOS)) && !IOSDownloadInProgress)
            {
                var path = Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathiOS);

                UpdatePlatformState(Path.Combine(path, IOSFrameworkName_UI), BuildTarget.iOS, enabled);
            }
        }
Example #16
0
        public static bool CheckAndroidFramework()
        {
            var pluginFolderPath = Path.Combine(GetSocialSettings.GetPluginPath(), DestinationFolderPathAndroid);
            var sdkVersion       = ReadSDKVersion(pluginFolderPath);

            if (DevelopmentVersion.Equals(sdkVersion))
            {
                return(true);
            }
            if (File.Exists(Path.Combine(pluginFolderPath, AndroidFrameworkName_Core)))
            {
                if (BuildConfig.UnitySdkVersion.Equals(sdkVersion))
                {
                    return(true);
                }
            }
            return(false);
        }
Example #17
0
        static void DrawAndroidSigningSignatureHash()
        {
            string     label   = "Signing-certificate fingerprint [?]";
            GUIContent content = new GUIContent(label,
                                                "SHA-256 hash of the keystore you use to sign your application.");

            var hasError = GetSocialEditorUtils.KeyStoreUtilError != null;

            if (hasError)
            {
                EditorGUILayout.BeginHorizontal();
                EditorGUILayout.LabelField(label, GUILayout.Height(16), EditorGuiUtils.OneThirdWidth);
                if (GUILayout.Button("More info", EditorStyles.miniButton, EditorGuiUtils.OneThirdWidth))
                {
                    Application.OpenURL(string.Format("https://docs.getsocial.im/knowledge-base/android-signing-key-sha256/?utm_source={0}&utm_medium=unity-editor", BuildConfig.PublishTarget));
                }
                if (GUILayout.Button("Refresh", EditorStyles.miniButton, EditorGuiUtils.OneThirdWidth))
                {
                    AssetDatabase.ImportAsset(GetSocialSettings.GetPluginPath() + Path.DirectorySeparatorChar +
                                              "Editor" + Path.DirectorySeparatorChar +
                                              "GetSocialSettingsEditor.cs");
                }
                EditorGUILayout.EndHorizontal();
            }
            else
            {
                EditorGuiUtils.SelectableLabelField(content, GetSocialEditorUtils.SigningKeyHash);
            }

            using (new EditorGUILayout.HorizontalScope())
            {
                if (!GetSocialEditorUtils.UserDefinedKeystore())
                {
                    EditorGUILayout.HelpBox("You are using default Android keystore to sign your application. Are you sure this is what you want?",
                                            MessageType.Warning);
                }
                else if (GetSocialEditorUtils.KeyStoreUtilError != null)
                {
                    EditorGUILayout.HelpBox(GetSocialEditorUtils.KeyStoreUtilError,
                                            MessageType.Warning);
                }
            }
        }
Example #18
0
        static void EmbedFrameworks(PBXProject project, string target)
        {
            string frameworksPath =
                GetSocialSettings.GetPluginPath().Substring(GetSocialSettings.GetPluginPath().IndexOf("/") + 1);
            string       defaultLocationInProj     = Path.Combine(Path.Combine("Frameworks", frameworksPath), "Plugins/iOS");
            const string coreFrameworkName         = "GetSocial.framework";
            const string uiFrameworkName           = "GetSocialUI.framework";
            var          relativeCoreFrameworkPath = Path.Combine(defaultLocationInProj, coreFrameworkName);
            var          relativeUiFrameworkPath   = Path.Combine(defaultLocationInProj, uiFrameworkName);

            project.AddDynamicFrameworkToProject(target, relativeCoreFrameworkPath);

            if (GetSocialSettings.UseGetSocialUi)
            {
                project.AddDynamicFrameworkToProject(target, relativeUiFrameworkPath);
            }
            else
            {
                project.RemoveDynamicFramework(relativeUiFrameworkPath);
            }
            Debug.Log("GetSocial: GetSocial Dynamic Frameworks added to Embedded binaries.");
        }
        static void AddNotificationExtension(PBXProject project, string projectPath)
        {
#if UNITY_2018_1_OR_NEWER
            const string extensionName = "/GetSocialNotificationExtension";
            if (!Directory.Exists(projectPath + extensionName))
            {
                Directory.CreateDirectory(projectPath + extensionName);
            }

            var           pluginDir = GetSocialSettings.GetPluginPath();
            PlistDocument notificationServicePlist = new PlistDocument();
            notificationServicePlist.ReadFromFile(pluginDir + "/Editor/iOS/Helpers/NotificationService/Info.plist");
            notificationServicePlist.root.SetString("CFBundleShortVersionString", PlayerSettings.bundleVersion);
            notificationServicePlist.root.SetString("CFBundleVersion", PlayerSettings.iOS.buildNumber);
            notificationServicePlist.WriteToFile(projectPath + "/GetSocialNotificationExtension/Info.plist");

            var extensionServiceSourceHeaderFile = pluginDir + "/Editor/iOS/Helpers/NotificationService/GetSocialNotificationService.h";
            var extensionServiceSourceImpFile    = pluginDir + "/Editor/iOS/Helpers/NotificationService/GetSocialNotificationService.m";
            var extensionServiceTargetHeaderFile = "GetSocialNotificationExtension/GetSocialNotificationService.h";
            var extensionServiceTargetImpFile    = "GetSocialNotificationExtension/GetSocialNotificationService.m";

            File.Copy(extensionServiceSourceHeaderFile, projectPath + "/" + extensionServiceTargetHeaderFile, true);
            File.Copy(extensionServiceSourceImpFile, projectPath + "/" + extensionServiceTargetImpFile, true);

            var mainTarget = project.TargetGuidByName(PBXProject.GetUnityTargetName());

            var appExtensionTarget = project.AddAppExtension(mainTarget, "GetSocialNotificationExtension", projectPath + "/GetSocialNotificationExtension/Info.plist");

            project.AddFileToBuild(appExtensionTarget, project.AddFile(extensionServiceTargetHeaderFile, extensionServiceTargetHeaderFile));
            project.AddFileToBuild(appExtensionTarget, project.AddFile(extensionServiceTargetImpFile, extensionServiceTargetImpFile));

            var frameworksPath =
                GetSocialSettings.GetPluginPath().Substring(GetSocialSettings.GetPluginPath().IndexOf("/") + 1);

            var relativeExtensionFrameworkPath = "Frameworks/" + frameworksPath + "/Plugins/iOS/GetSocialNotificationExtension.framework";

            project.AddFileToBuild(appExtensionTarget, project.FindFileGuidByProjectPath(relativeExtensionFrameworkPath));

            var deviceFamily = "";
            switch (PlayerSettings.iOS.targetDevice)
            {
            case iOSTargetDevice.iPhoneOnly:
                deviceFamily = "1";
                break;

            case iOSTargetDevice.iPadOnly:
                deviceFamily = "2";
                break;

            case iOSTargetDevice.iPhoneAndiPad:
                deviceFamily = "1,2";
                break;
            }


            project.SetBuildProperty(appExtensionTarget, "TARGETED_DEVICE_FAMILY", deviceFamily);
            if (double.Parse(PlayerSettings.iOS.targetOSVersionString) > 10)
            {
                project.SetBuildProperty(appExtensionTarget, "IPHONEOS_DEPLOYMENT_TARGET", PlayerSettings.iOS.targetOSVersionString.ToString());
            }
            else
            {
                project.SetBuildProperty(appExtensionTarget, "IPHONEOS_DEPLOYMENT_TARGET", "10.0");
            }

            project.SetBuildProperty(appExtensionTarget, "DEVELOPMENT_TEAM", PlayerSettings.iOS.appleDeveloperTeamID);
            project.SetBuildProperty(appExtensionTarget, "PRODUCT_BUNDLE_IDENTIFIER", GetSocialSettings.ExtensionBundleId);
            project.SetBuildProperty(appExtensionTarget, "CODE_SIGN_STYLE", PlayerSettings.iOS.appleEnableAutomaticSigning ?  "Automatic" : "Manual");
            if (!PlayerSettings.iOS.appleEnableAutomaticSigning)
            {
                if (GetSocialSettings.ExtensionProvisioningProfile.Length == 0)
                {
                    Debug.LogError("Notification Extension Provisioning Profile must be specified.");
                }
                else
                {
                    project.SetBuildProperty(appExtensionTarget, "PROVISIONING_PROFILE", GetSocialSettings.ExtensionProvisioningProfile);
                    project.SetBuildProperty(appExtensionTarget, "PROVISIONING_PROFILE_SPECIFIER", GetSocialSettings.ExtensionProvisioningProfile);
                }
            }
            project.AddFrameworkToProject(mainTarget, "UserNotifications.framework", false);
            AddExtensionEntitlements(projectPath, project, appExtensionTarget);
#endif
        }