2016-10-20 7 views
6

जब मेरा ऐप अग्रभूमि में है, तो एक चेतावनी दिखाई देती है। पुश नोटिफिकेशन प्राप्त करते समय मैं इसे कैसे दिखने से रोक सकता हूं?आने वाली वन सिग्नल पुश अधिसूचना के साथ ऐप फोरग्राउंड पर होने पर अलर्ट को कैसे रोकूं?

उत्तर

7

AppDelegate के अपने didFinishLaunchingWithOptions विधि में आप मैं इसे इस तरह से हासिल kOSSettingsKeyInAppAlerts = NO

[OneSignal initWithLaunchOptions:launchOptions appId:ONESIGNAL_APPID handleNotificationReceived:nil handleNotificationAction:nil 
          settings:@{kOSSettingsKeyInAppAlerts:@NO}]; 
+2

नोट किया है कि 'kOSSettingsKeyInAppAlerts' अब है बहिष्कृत और 'kOSSettingsKeyInFocusDisplayOption' instea का उपयोग किया जाना चाहिए घ। – jkasten

3

डिफ़ॉल्ट रूप से OneSignal ऐप इन्फोकस होने पर चेतावनी संवाद के रूप में सूचनाएं दिखाता है। initWithLaunchOptions पर सेटिंग्स के लिए OSNotificationDisplayTypeNotification या OSNotificationDisplayTypeNone के साथ को इस पास को बदलने के लिए।

6

जोड़ने के लिए स्विफ्ट 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]) 
0

के लिए की है।

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey : Any]? = nil) -> Bool { 

OneSignal.inFocusDisplayType = OSNotificationDisplayType.none 
return true } 

में अपने AppDelegate didFinishLaunchingWithOptions

OneSignal.inFocusDisplayType = OSNotificationDisplayType.none 

अंतिम पंक्ति पर में निम्न कोड जोड़ें हम इन 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 Documentation

संबंधित मुद्दे