public Configuration() { Windows = new WindowsConfiguration(this); Android = new AndroidConfiguration(this); iOS = new iOSConfiguration(this); MacOS = new MacOSConfiguration(this); Web = new WebConfiguration(this); }
public void RegisterTypes(IContainerRegistry containerRegistry) { // Register any platform specific implementations containerRegistry.RegisterDelegate <IConfigurationManager>(() => ConfigurationManager.Current); var droidConfiguration = new iOSConfiguration(ConfigurationManager.Current); containerRegistry.RegisterInstance <IEnvironmentConfiguration>(droidConfiguration); Constants.Initialize(droidConfiguration); containerRegistry.RegisterInstance <IModuleCatalogInitializer>(this); containerRegistry.Register <Covi.Services.Http.IHttpClientHandlerProvider, Services.Http.NativeHttpClientHandlerProvider>(); containerRegistry.RegisterDelegate <Covi.Features.BluetoothTracing.IPlatformTracingEngine>(() => { return(Features.Bluetooth.TracingEngine.Instance); }); containerRegistry.Register <IPushNotificationInitializer, PushNotificationPermissionInitializer>(); }
public static void CreateRichPushNotificationTarget(BuildTarget buildTarget, string buildOutputPath) { iOSConfiguration config = iOSConfiguration.Load(); if (!config.enableRichPushNotifications) { return; } string xcodeProjectPath = PBXProject.GetPBXProjectPath(buildOutputPath); PBXProject project = new PBXProject(); project.ReadFromFile(xcodeProjectPath); string guidOfInitialTarget = GetTargetGuid(project); string pathToInfoPlist = Path.Combine(buildOutputPath, PATH_TO_INFO_PLIST_INSIDE_TARGET); PlistDocument mainProjectInfoPlist = new PlistDocument(); mainProjectInfoPlist.ReadFromFile(pathToInfoPlist); PlistElementArray array = mainProjectInfoPlist.root.CreateArray("UIBackgroundModes"); array.AddString("remote-notification"); mainProjectInfoPlist.WriteToFile(pathToInfoPlist); string bundleIdentifierForNotificationService = config.pushNotificationServiceExtensionIdentifier; int indexOfLastIdentifierSection = bundleIdentifierForNotificationService.LastIndexOf('.') + 1; string displayName = bundleIdentifierForNotificationService.Substring(indexOfLastIdentifierSection); string pathToNotificationServiceImplementation = Path.Combine(buildOutputPath, displayName); if (!Directory.Exists(pathToNotificationServiceImplementation)) { Directory.CreateDirectory(pathToNotificationServiceImplementation); } PlistDocument notificationServicePlist = new PlistDocument(); string plistTemplatePath = Path.Combine(GetPathToSourceDirectory(), "Info.plist"); notificationServicePlist.ReadFromFile(plistTemplatePath); notificationServicePlist.root.SetString("CFBundleDisplayName", displayName); notificationServicePlist.root.SetString("CFBundleIdentifier", bundleIdentifierForNotificationService); notificationServicePlist.root.SetString("CFBundleShortVersionString", PlayerSettings.bundleVersion); notificationServicePlist.root.SetString("CFBundleVersion", PlayerSettings.iOS.buildNumber.ToString()); string pathToNotificationServicePlist = Path.Combine(pathToNotificationServiceImplementation, PATH_TO_INFO_PLIST_INSIDE_TARGET); notificationServicePlist.WriteToFile(pathToNotificationServicePlist); string guidOfExtension = PBXProjectExtensions.AddAppExtension( project, guidOfInitialTarget, displayName, PlayerSettings.GetApplicationIdentifier(BuildTargetGroup.iOS) + ".notificationservice", pathToNotificationServicePlist ); string buildPhaseId = project.AddSourcesBuildPhase(guidOfExtension); AddSourceFileToProject( project, "NotificationService.h", displayName, guidOfExtension, buildPhaseId, pathToNotificationServiceImplementation ); AddSourceFileToProject( project, "NotificationService.m", displayName, guidOfExtension, buildPhaseId, pathToNotificationServiceImplementation ); AddFileToProject( project, pathToNotificationServicePlist, "Info.plist", displayName, guidOfExtension, buildPhaseId ); project.AddFrameworkToProject(guidOfExtension, "NotificationCenter.framework", true); project.AddFrameworkToProject(guidOfExtension, "UserNotifications.framework", true); project.SetBuildProperty(guidOfExtension, "ARCHS", "$(ARCHS_STANDARD"); project.SetBuildProperty(guidOfExtension, "DEVELOPMENT_TEAM", PlayerSettings.iOS.appleDeveloperTeamID); string[] copyableProperties = { "IPHONEOS_DEPLOYMENT_TARGET", "TARGETED_DEVICE_FAMILY" }; foreach (string copyableProperty in copyableProperties) { string originalBuildProperty = project.GetBuildPropertyForAnyConfig(guidOfInitialTarget, copyableProperty); project.SetBuildProperty(guidOfExtension, copyableProperty, originalBuildProperty); } project.WriteToFile(xcodeProjectPath); }