2016-10-20 12 views

答えて

7

は、私はそれをこのように実現スウィフト3.0

// Initialize OngeSignal with Settings for Push Notifications 
    OneSignal.initWithLaunchOptions(launchOptions, appId: Constants.OneSignalAppID, handleNotificationReceived: nil, handleNotificationAction: { 
     (result) in 
     // Do Something with Notification Result 
    }, settings: [kOSSettingsKeyInFocusDisplayOption : OSNotificationDisplayType.none.rawValue]) 
+2

注意だ

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { OneSignal.inFocusDisplayType = OSNotificationDisplayType.none return true } 

に、我々はこれらの3つのオプション

public enum OSNotificationDisplayType : UInt { /*Notification is silent, or app is in focus but InAppAlertNotifications are disabled*/ case none /*Default UIAlertView display*/ case inAppAlert /*iOS native notification display*/ case notification } 

を持っている最後の行に

OneSignal.inFocusDisplayType = OSNotificationDisplayType.none 

あなたのAppDelegateのdidFinishLaunchingWithOptionsに次のコードを追加します。非推奨であり、 'kOSSettingsKeyInFocusDisplayOption'をinsteaで使うべきですd。 – jkasten

3

デフォルトでは、OneSignalは、アプリがインフォーカスのときに警告ダイアログとして通知を表示します。このパスを変更するには、OSNotificationDisplayTypeNotificationまたはOSNotificationDisplayTypeNoneの値を持つkOSSettingsKeyInFocusDisplayOptioninitWithLaunchOptionsの設定に変更します。 AppDelegateのごdidFinishLaunchingWithOptions方法で

0

についてkOSSettingsKeyInAppAlerts = NO

[OneSignal initWithLaunchOptions:launchOptions appId:ONESIGNAL_APPID handleNotificationReceived:nil handleNotificationAction:nil 
          settings:@{kOSSettingsKeyInAppAlerts:@NO}]; 
関連する問題