11//
22// AppCenterSDK+SMFLogger.swift
3- // Newsletter2Go
3+ // SmartMobileFactory
44//
55// Created by Konstantin Deichmann on 11.09.19.
6- // Copyright © 2019 Newsletter2Go GmbH . All rights reserved.
6+ // Copyright © 2019 SmartMobileFactory . All rights reserved.
77//
88
99import Foundation
@@ -41,7 +41,8 @@ class AppCenterSDK: NSObject {
4141
4242 // MARK: - Methods
4343
44- /// This will setup the SentrySDK with the common base configuration. Crashes will be detected if the app is build with the release build type and the sentry dsn taken from the info plists.
44+ /// This will setup the AppCenterSDK with the common base configuration. Crashes will be detected if the app is build with the release build type.
45+ /// Distribution can be enabled using the configuration
4546 ///
4647 /// - Parameters:
4748 /// - configuration: Configuration object
@@ -55,6 +56,25 @@ class AppCenterSDK: NSObject {
5556 MSAppCenter . start ( configuration. appSecret, withServices: services)
5657 }
5758
59+ /// Returns True, if and only if the Service got started and is enabled.
60+ var isDistributionEnabled : Bool {
61+ return MSDistribute . isEnabled ( )
62+ }
63+
64+ /// Will enable or disable the Distribution Feature of AppCenter
65+ /// While disabling works always.
66+ /// For enabling the Setup (aka. start) - Method should be called before.
67+ ///
68+ /// Flow in the App, for Apps that want to dynamically change that State:
69+ /// - Call the Setup Method for with `isDistributionEnabled` set to true.
70+ /// - Disable Distribution using `enableDistribution(enabled: false)`
71+ /// - Enable Distribution at a later time using the same method
72+ ///
73+ /// - Parameter enabled: Enable or Disable Distribtion
74+ func enableDistribution( enabled: Bool = true ) {
75+ MSDistribute . setEnabled ( enabled)
76+ }
77+
5878 /// This will create a `fatalError` to crash the app.
5979 static func performTestCrash( ) {
6080
@@ -68,12 +88,14 @@ extension AppCenterSDK {
6888
6989 fileprivate var enableDebug : Bool = false
7090 fileprivate var appSecret : String = " "
71- fileprivate var isDistributionEnabled : Bool
91+ fileprivate var isDistributionEnabled : Bool = false
7292
7393 /// Initializes a AppCenterSDK Configuration
7494 ///
7595 /// - Parameters:
7696 /// - appSecret: supply this manually if you dont want it in the info.plist
97+ /// - enableDebug: Should start the Services even for Debug, Default is false
98+ /// - isDistributionEnabled: Should start the Distribution Service, Default is false for Debug and Live apps, else true,
7799 init ( appSecret: String ? = nil , enableDebug: Bool = false , isDistributionEnabled: Bool ? = nil ) {
78100
79101 let appSecretFromBundle = Bundle . main. object ( forInfoDictionaryKey: AppCenterConstants . appSecretKey) as? String
0 commit comments