registerForRemoteNotificationTypes: iOS 8.0 और बाद में समर्थित नहीं है


209

IOS 8.x के तहत पुश सूचनाओं के लिए पंजीकरण करने का प्रयास करते समय:

application.registerForRemoteNotificationTypes(UIRemoteNotificationType.Alert | UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound)

मुझे निम्नलिखित त्रुटि मिलती है:

registerForRemoteNotificationTypes: is not supported in iOS 8.0 and later.

किसी भी विचार यह करने का नया तरीका क्या है? यह काम करता है जब मैं इस स्विफ्ट ऐप को iOS 7.x पर चलाता हूं।

संपादित करें

IOS 7.x पर जब मुझे सशर्त कोड मिलता है तो मुझे या तो SystemVersion सशर्त मिलता है या #if __IPHONE_OS_VERSION_MAX_ALLOWED> = 80000)

dyld: Symbol not found: _OBJC_CLASS_$_UIUserNotificationSettings

1
UIApplication के प्रलेखन को देखें, मुझे लगता है कि आप registerUserNotificationSettings और registerForRemoteNotifications का उपयोग करने वाले हैं।
14

3
धन्यवाद, मैं जांच करूंगा कि सोमवार को
वोजटेक ट्यूरिकस

@Skyte: यह विधि केवल iOS 8+ में उपलब्ध है
user102008

किसी को भी पता है कि क्यों अभी भी ऐप स्टोर में पहले से ही एक ऐप के साथ काम करता है, लेकिन अगर मैं इसे स्थानीय रूप से परीक्षण करने की कोशिश नहीं करता हूं?
最白目

1
क्या यह निर्भर करता है कि बाइनरी किस xCode संस्करण के साथ बनाया गया था? एक पंक्ति में 2 टिप्पणियों के लिए क्षमा करें, मुझे अपनी उपरोक्त टिप्पणी को संपादित करने में बहुत देर हो गई।
59 目 12

जवाबों:


145

जैसा कि आपने वर्णित किया है, आपको आईओएस के विभिन्न संस्करणों के आधार पर एक अलग विधि का उपयोग करने की आवश्यकता होगी। यदि आपकी टीम Xcode 5 (जो किसी भी iOS 8 चयनकर्ताओं के बारे में नहीं जानती) और Xcode 6 दोनों का उपयोग कर रही है, तो आपको निम्नानुसार सशर्त संकलन का उपयोग करने की आवश्यकता होगी:

#if __IPHONE_OS_VERSION_MAX_ALLOWED >= 80000
if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
    // use registerUserNotificationSettings
} else {
    // use registerForRemoteNotificationTypes:
}
#else
// use registerForRemoteNotificationTypes:
#endif

यदि आप केवल Xcode 6 का उपयोग कर रहे हैं, तो आप बस इसी के साथ रह सकते हैं:

if ([application respondsToSelector:@selector(registerUserNotificationSettings:)]) {
    // use registerUserNotificationSettings
} else {
    // use registerForRemoteNotificationTypes:
}

इसका कारण यह है कि iOS 8 में आपको नोटिफिकेशन की अनुमति मिलने का तरीका बदल UserNotificationगया है। उपयोगकर्ता को एक संदेश दिखाया जाता है, चाहे वह रिमोट से हो या लोकल से। आपको एक दिखाने के लिए अनुमति लेनी होगी। यह WWDC 2014 के वीडियो "आईओएस नोटिफिकेशन में नया क्या है" में वर्णित है


11
@ मैट - क्या आपके पास एक संदर्भ है कि क्यों iOS8 में पुश भेजने की अनुमति प्राप्त करने के लिए ऐप्पल ने पिछले एपीआई को तोड़ा है? मैंने अपने कोड में एक ही काम किया है, लेकिन मुझे अपनी कंपनी में दूसरों को यह समझाने के लिए कुछ आधिकारिक दस्तावेज़ साझा करने की आवश्यकता है।
क्रिश सुब्रमण्यन

3
@ KrisSubramanian सबसे अच्छा संदर्भ मेरे पास पूर्व-जारी प्रलेखन है : "ऐसे ऐप्स जो स्थानीय या पुश अधिसूचना के साथ संयोजन में दृश्यमान या श्रव्य अलर्ट का उपयोग करते हैं, उन्हें उन प्रकार के अलर्ट को पंजीकृत करना होगा जो वे काम करते हैं।" जैसा कि "क्यों," मेरे पास केवल मेरी व्याख्या है: संदेशों की परवाह किए बिना अंत-उपयोगकर्ता की सुविधा, स्रोत की परवाह किए बिना।
मैट ---

2
आप इसके __IPHONE_OS_VERSION_MAX_ALLOWEDलिए जाँच करने के लिए उपयोग नहीं कर सकते क्योंकि यह एक संकलन-समय की जाँच है।
रोब केनगर

5
एक संकलन-समय की जाँच है जो आपको Xcode 5 के मामले में चाहिए।
मैट ---

1
@woheras यहाँregisterUserNotificationSettings: प्रलेखित है
मैट ---

334

IOS <10 के लिए

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
    //-- Set Notification
    if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) 
    {
           // iOS 8 Notifications
           [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];

           [application registerForRemoteNotifications];
    }
    else
    {
          // iOS < 8 Notifications
          [application registerForRemoteNotificationTypes:
                     (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
    }

     //--- your custom code
     return YES;
}

IOS10 के लिए

https://stackoverflow.com/a/39383027/3560390


यदि आप वास्तव में यह सुनिश्चित करना चाहते हैं कि अलर्ट दिखाने के लिए उपयोगकर्ता की अनुमति प्राप्त करने से पहले आप अपना पहला नोटिफिकेशन नहीं भेजना चाहते हैं, तो registerUorNotificationSettings के कॉलबैक से registerForRemoteNotifications कैसे कॉल करें?
मोहम्मद हाफिज

5
चेक की बजाय systemVersion, आपको जांच करनी चाहिए[[UIApplication sharedApplication] respondsToSelector:@selector(isRegisteredForRemoteNotifications)]
एंडी

1
[[UIApplication sharedApplication] registerForRemoteNotifications];सेटिंग्स में -> नोटिफ़िकेशन -> नोटिफिकेशन -> <My App> में कोई उपयोगकर्ता अक्षम "अनुमति सूचनाएँ" पर नहीं जाएगा application:didRegisterForRemoteNotificationsWithDeviceToken:या नहीं जाएगा application:didFailToRegisterForRemoteNotificationsWithError:
प्रोटोकॉल

IMO Apple को पूरी तरह से हटाने के बजाय iOS 8 में फ़ंक्शन को पूरी तरह से हटा दिया जाना चाहिए, या पीछे की संगतता के लिए प्रदान किया जाना चाहिए। जिस तरह से यह अब है, कई ऐप में पुश नोटिफिकेशन चुपचाप विफल हो रहे हैं और डेवलपर्स अब इस मुद्दे को पैच करने के लिए स्क्रैच कर रहे हैं।
जोश लिप्टज़िन

7
IMO उन्हें पीछे की संगतता को नहीं तोड़ना चाहिए था। देखो कि आपके कोड को दोनों संस्करणों का समर्थन करने के लिए कितना बदसूरत होना पड़ता है, जैसा कि एक पंक्ति से पहले था। नए लोगों के संदर्भ में अपने पुराने APIs को फिर से लागू करना एक ठोस तकनीक है और इसके परिणामस्वरूप बहुत कम नाराज डेवलपर्स हैं। Apple के रवैये का मतलब है कि यह iOS ऐप को सपोर्ट करने के लिए एक दर्द है, जहाँ कार्यक्षमता के स्तर को 2 साल से कम रखने का प्रयास गैर-तुच्छ है।
रॉबी_के

23

@ प्रसाद के उत्तर पर बिल्डिंग। यह आप इसे स्विफ्ट में कैसे करते हैं :

if application.respondsToSelector("isRegisteredForRemoteNotifications")
{
    // iOS 8 Notifications
    application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: (.Badge | .Sound | .Alert), categories: nil));
    application.registerForRemoteNotifications()
}
else
{
    // iOS < 8 Notifications
    application.registerForRemoteNotificationTypes(.Badge | .Sound | .Alert)
}

14

iOS 8 ने गैर-पीछे संगत तरीके से अधिसूचना पंजीकरण को बदल दिया है। जब आपको आईओएस 7 और 8 का समर्थन करने की आवश्यकता होती है (और 8 एसडीके के साथ निर्मित एप्लिकेशन स्वीकार नहीं किए जाते हैं), तो आप उन चयनकर्ताओं की जांच कर सकते हैं जिनकी आपको जरूरत है और सशर्त रूप से रनिंग संस्करण के लिए उन्हें सही ढंग से कॉल करें।

यहाँ UIApplication पर एक श्रेणी दी गई है जो आपके लिए एक क्लीन इंटरफ़ेस के पीछे इस तर्क को छिपाएगा जो Xcode 5 और Xcode 6 दोनों में काम करेगा।

हैडर:

//Call these from your application code for both iOS 7 and 8
//put this in the public header
@interface UIApplication (RemoteNotifications)

- (BOOL)pushNotificationsEnabled;
- (void)registerForPushNotifications;

@end

कार्यान्वयन:

//these declarations are to quiet the compiler when using 7.x SDK
//put this interface in the implementation file of this category, so they are
//not visible to any other code.
@interface NSObject (IOS8)

- (BOOL)isRegisteredForRemoteNotifications;
- (void)registerForRemoteNotifications;

+ (id)settingsForTypes:(NSUInteger)types categories:(NSSet*)categories;
- (void)registerUserNotificationSettings:(id)settings;

@end

@implementation UIApplication (RemoteNotifications)

- (BOOL)pushNotificationsEnabled
{
    if ([self respondsToSelector:@selector(isRegisteredForRemoteNotifications)])
    {
        return [self isRegisteredForRemoteNotifications];
    }
    else
    {
        return ([self enabledRemoteNotificationTypes] & UIRemoteNotificationTypeAlert);
    }
}

- (void)registerForPushNotifications
{
    if ([self respondsToSelector:@selector(registerForRemoteNotifications)])
    {
        [self registerForRemoteNotifications];

        Class uiUserNotificationSettings = NSClassFromString(@"UIUserNotificationSettings");

        //If you want to add other capabilities than just banner alerts, you'll need to grab their declarations from the iOS 8 SDK and define them in the same way.
        NSUInteger UIUserNotificationTypeAlert   = 1 << 2;

        id settings = [uiUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert categories:[NSSet set]];            
        [self registerUserNotificationSettings:settings];

    }
    else
    {
        [self registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert];
    }
}

@end

5
मैं बस विश्वास नहीं कर सकता कि यह चीजें क्यों नहीं बनती हैं Apple और डेवलपर्स को इस तरह की चीजें बनाने की जरूरत होती है जब भी Apple एक विधि को चित्रित करता है। IOS का हर नया वर्जन यही है। कोड को फिर से लिखना दुखद है क्योंकि Apple पुराने तरीकों को चित्रित करता है।
19

2
मुझे लगता है कि यह इतना है कि चीजों को समय के साथ बेहतर हो जाता है क्योंकि पुराने स्कैब के शीर्ष पर केवल अन्य ऑपरेटिंग सिस्टम की तरह बेंडिड्स जोड़ने के बजाय मैं सोच सकता हूं।
पॉल ब्रुनो

मेरे परीक्षणों से (जिसमें पूरा दिन लगा), अगर मैं जाकर Settingsसूचनाओं को निष्क्रिय करता हूं , तब isRegisteredForRemoteNotificationsभी रिटर्न करता हैYES
Iulian Onofrei

एक उचित समाधान जोड़ने के लिए अंगूठे: अप्रत्यक्ष की एक और परत!
बर्कस

6

मुझे लगता है कि यह बैकवर्ड संगतता बनाए रखने का बेहतर तरीका है यदि हम इस दृष्टिकोण के साथ जाते हैं, तो यह मेरे मामले के लिए काम कर रहा है और आशा है कि यह आपके लिए काम करेगा। इसके अलावा समझने के लिए बहुत आसान है।

if ([[[UIDevice currentDevice] systemVersion] floatValue] >= 8.0)
{
    [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];
    [[UIApplication sharedApplication] registerForRemoteNotifications];
}
else
{
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
         (UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert)];
}

यहांif ([UIApplication instancesRespondToSelector:@selector(registerForRemoteNotifications)]) दिखाए गए अनुसार बेहतर उपयोग
इलियान ओनोफ्रेई

5

स्विफ्ट-झुकाव के लिए:

if let registration: AnyObject = NSClassFromString("UIUserNotificationSettings") { // iOS 8+
    let notificationTypes: UIUserNotificationType = (.Alert | .Badge | .Sound)
    let notificationSettings: UIUserNotificationSettings = UIUserNotificationSettings(forTypes: notificationTypes, categories: nil)

    application.registerUserNotificationSettings(notificationSettings)
} else { // iOS 7
    application.registerForRemoteNotificationTypes(.Alert | .Badge | .Sound)
}

3
स्विफ्ट 2.0 में, जैसा कि मैं समझता हूं कि आपको सेट में विकल्प प्रदान करना चाहिए ।Alert, .Badge, .Sound] क्योंकि ((.Alert) .Badge | .Sound) ने मेरे लिए काम नहीं किया।
अपान

3

मैं यह नहीं पता लगा सका कि "श्रेणियों" एनएसएसईटी चर को किसके लिए सेट किया जाना चाहिए, इसलिए यदि कोई मुझे भर सकता है तो मैं इस पोस्ट को ख़ुशी से संपादित करूंगा। हालाँकि, निम्न सूचना संवाद को ऊपर लाती है।

[[UIApplication sharedApplication] registerForRemoteNotifications];
UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge | UIUserNotificationTypeSound | UIUserNotificationTypeAlert) categories:nil];
[[UIApplication sharedApplication] registerUserNotificationSettings:settings];

संपादित करें: मुझे इस कोड के साथ अपने फोन को भेजने के लिए एक धक्का सूचना मिली, इसलिए मुझे यकीन नहीं है कि श्रेणियां पैरामीटर आवश्यक हैं।


हां यह iOS8 पर काम करता है लेकिन मैं इसे iOS7 के साथ कैसे पीछे कर सकता हूं? iOS7 पर यह दुर्घटनाग्रस्त हो जाएगा। IOS वर्जन चेक करने से मदद नहीं मिलती है क्योंकि iOS7 नए सिंबल को दोबारा मान्यता नहीं देता है।
वोजटेक टुरीविज़

2
categoriesIOS 8 में अधिसूचना क्रियाएँ स्थापित करने के लिए प्रयोग किया जाता है। आप अधिक विवरण के लिए WWDC 2014 के वीडियो "व्हाट्स न्यू इन आईओएस नोटिफिकेशन" देख सकते हैं
मैट ---

3

तो यह पता चला है कि AnyObject आईडी के लिए आध्यात्मिक उत्तराधिकारी है, आप किसी भी संदेश को AnyObject पर कॉल कर सकते हैं। वह आईडी पर एक संदेश भेजने के बराबर है। ठीक है पर्याप्त ठीक है। लेकिन अब हम इस अवधारणा में जोड़ते हैं कि AnyObject पर सभी तरीके वैकल्पिक हैं , और हमारे पास कुछ ऐसा है जिसके साथ हम काम कर सकते हैं।

उपरोक्त को देखते हुए, मुझे उम्मीद थी कि मैं AnyObject में UIApplication.saredApplication () कर सकता हूं, फिर विधि हस्ताक्षर के बराबर एक चर बनाएं, उस चर को वैकल्पिक विधि पर सेट करें, फिर चर का परीक्षण करें। यह काम नहीं लगता था। मेरा अनुमान है कि जब आईओएस 8.0 एसडीके के खिलाफ संकलित किया जाता है, तो कंपाइलर जानता है कि यह कहां लगता है कि विधि होनी चाहिए, इसलिए यह एक मेमोरी लुकअप के लिए नीचे सभी को अनुकूलित करता है। जब तक मैं चर का परीक्षण करने की कोशिश नहीं करता, तब तक सब कुछ ठीक रहता है, जिस समय मुझे एक EXC_BAD_ACCESS मिलता है।

हालांकि, उसी WWDC में जहां मैंने सभी तरीकों के वैकल्पिक होने के बारे में मणि पाया, वे वैकल्पिक विधि को कॉल करने के लिए वैकल्पिक चैनिंग का उपयोग करते हैं - और यह काम करने लगता है। लंगड़ा हिस्सा यह है कि आपको वास्तव में यह जानने के लिए विधि को कॉल करने का प्रयास करना है कि क्या यह मौजूद है, जो सूचनाओं के लिए पंजीकरण के मामले में एक समस्या है, क्योंकि आप यह पता लगाने की कोशिश कर रहे हैं कि क्या यह विधि आपके द्वारा बनाए जाने से पहले मौजूद है UIUserNotificationSettings ऑब्जेक्ट। ऐसा लगता है कि शून्य से उस पद्धति को कॉल करना ठीक है, इसलिए जो समाधान मेरे लिए काम कर रहा है वह है:

var ao: AnyObject = UIApplication.sharedApplication()
if let x:Void = ao.registerUserNotificationSettings?(nil) {
    // It's iOS 8
    var types = UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert
    var settings = UIUserNotificationSettings(forTypes: types, categories: nil)
    UIApplication.sharedApplication().registerUserNotificationSettings(settings)
} else {
    // It's older
    var types = UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound | UIRemoteNotificationType.Alert
    UIApplication.sharedApplication().registerForRemoteNotificationTypes(types)
}

इससे संबंधित बहुत खोज करने के बाद, प्रमुख जानकारी इस WWDC से आई है https://developer.apple.com/videos/wwdc/2014/#407 "अनुभाग में प्रोटोकॉल में वैकल्पिक तरीके" के बारे में।

Xcode 6.1 बीटा में उपरोक्त कोड अब काम नहीं करता है, नीचे दिया गया कोड काम करता है:

   if UIApplication.sharedApplication().respondsToSelector("registerUserNotificationSettings:") {
        // It's iOS 8
        var types = UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert
       var settings = UIUserNotificationSettings(forTypes: types, categories: nil)
       UIApplication.sharedApplication().registerUserNotificationSettings(settings)
    } else {
        // It's older
        var types = UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound | UIRemoteNotificationType.Alert
        UIApplication.sharedApplication().registerForRemoteNotificationTypes(types)
    }

3

यदि आप IOS7 IOS8 को समर्थन जोड़ना पसंद करते हैं, तो आप इस कोड को अपनी परियोजना में लागू कर सकते हैं।

-(void) Subscribe {
    NSLog(@"Registering for push notifications...");

    if ([[UIApplication sharedApplication] respondsToSelector:@selector(registerUserNotificationSettings:)]) {
        UIUserNotificationSettings* notificationSettings = [UIUserNotificationSettings settingsForTypes:UIUserNotificationTypeAlert | UIUserNotificationTypeBadge | UIUserNotificationTypeSound categories:nil];
        [[UIApplication sharedApplication] registerUserNotificationSettings:notificationSettings];
        [[UIApplication sharedApplication] registerForRemoteNotifications];
    } else {
        [[UIApplication sharedApplication] registerForRemoteNotificationTypes: (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];
    }
}

-(void)application:(UIApplication *)application 
    didRegisterUserNotificationSettings:(UIUserNotificationSettings *)notificationSettings {

    if (notificationSettings.types) {
        NSLog(@"user allowed notifications");
        [[UIApplication sharedApplication] registerForRemoteNotifications];
    } else {
        NSLog(@"user did not allow notifications");
        UIAlertView *alert =[[UIAlertView alloc] 
            initWithTitle:@"Please turn on Notification"
            message:@"Go to Settings > Notifications > App.\n Switch on Sound, Badge & Alert"
            delegate:self
            cancelButtonTitle:@"Ok"
            otherButtonTitles: nil];
        [alert show];
        // show alert here
    }
}

2

Xcode 6.1 के बाद कोड नीचे काम करता है, टॉम S कोड पर थोड़ा संपादित करें जिसने 6.1 बीटा के साथ काम करना बंद कर दिया (पिछले बीटा के साथ काम किया):

   if UIApplication.sharedApplication().respondsToSelector("registerUserNotificationSettings:") {
        // It's iOS 8
        var types = UIUserNotificationType.Badge | UIUserNotificationType.Sound | UIUserNotificationType.Alert
       var settings = UIUserNotificationSettings(forTypes: types, categories: nil)
       UIApplication.sharedApplication().registerUserNotificationSettings(settings)
    } else {
        // It's older
        var types = UIRemoteNotificationType.Badge | UIRemoteNotificationType.Sound | UIRemoteNotificationType.Alert
        UIApplication.sharedApplication().registerForRemoteNotificationTypes(types)
    }

2

आप इसका उपयोग कर सकते हैं

if ([application respondsToSelector:@selector(isRegisteredForRemoteNotifications)]) 
    {
        // for iOS 8
        [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]];

        [application registerForRemoteNotifications];
    }
    else
    {
        // for iOS < 8
        [application registerForRemoteNotificationTypes:
         (UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeSound)];
    }

    // RESET THE BADGE COUNT 
    application.applicationIconBadgeNumber = 0;

2

स्विफ्ट 2.0

// Checking if app is running iOS 8
    if application.respondsToSelector("isRegisteredForRemoteNotifications") {

        print("registerApplicationForPushNotifications - iOS 8")

        application.registerUserNotificationSettings(UIUserNotificationSettings(forTypes: [.Alert, .Badge, .Sound], categories: nil));
        application.registerForRemoteNotifications()

    } else {
        // Register for Push Notifications before iOS 8
        print("registerApplicationForPushNotifications - <iOS 8")
        application.registerForRemoteNotificationTypes([UIRemoteNotificationType.Alert, UIRemoteNotificationType.Badge, UIRemoteNotificationType.Sound])

    }

1

यदि आप सभी की जरूरत है ios 8 कोड है, यह यह करना चाहिए।

 - (BOOL)application:(UIApplication *)application       didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{
       [application registerUserNotificationSettings: [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound  | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge)  categories:nil]];

       [application registerForRemoteNotifications];
}

 return YES;
}

0

यह क्लीनर तरीका है जो मैं कर रहा हूं और यह सिर्फ महान काम करता है

if (floor(NSFoundationVersionNumber) < NSFoundationVersionNumber_iOS_8_0)
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge|
     UIRemoteNotificationTypeAlert| UIRemoteNotificationTypeSound];
     else {
         [application registerUserNotificationSettings:[UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge) categories:nil]]; 
         [application registerForRemoteNotifications];
     }

0

iOS 8 और इसके बाद के संस्करण के लिए

UIUserNotificationSettings *settings = [UIUserNotificationSettings settingsForTypes:(UIUserNotificationTypeBadge|UIUserNotificationTypeSound|UIUserNotificationTypeAlert) categories:nil];
[application registerUserNotificationSettings:settings];
हमारी साइट का प्रयोग करके, आप स्वीकार करते हैं कि आपने हमारी Cookie Policy और निजता नीति को पढ़ और समझा लिया है।
Licensed under cc by-sa 3.0 with attribution required.