8

किसी को भी मुझे आईओएस 10 के लिए पुश अधिसूचना को लागू करने के रूप में मैं लागू कर दिया है कोड निम्नलिखित लेकिन अभी भी उस में समस्या हो रही है के साथ मदद कर सकते हैं:आईओएस 10 [उद्देश्य सी] के लिए पुश अधिसूचना को कैसे कार्यान्वित करें?

#define SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(v) ([[[UIDevice currentDevice] systemVersion] compare:v options:NSNumericSearch] != NSOrderedAscending) 

if(SYSTEM_VERSION_GRATERTHAN_OR_EQUALTO(@"10.0")) 
{ 
    UNUserNotificationCenter *center = [UNUserNotificationCenter currentNotificationCenter]; 
    center.delegate = self; 
    [center requestAuthorizationWithOptions:(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge) completionHandler:^(BOOL granted, NSError * _Nullable error){ 
     if(!error){ 
      [[UIApplication sharedApplication] registerForRemoteNotifications]; 
     } 
    }]; 
} 
else { 
    // Code for old versions 
} 

मैं सुझाव है कि

अज्ञात रिसीवर UIUserNotificationCenter

त्रुटि हो रही है

अग्रिम धन्यवाद!

+0

यह देखने http://stackoverflow.com/questions/39382852/didreceiveremotenotification-not-called-ios-10/39383027 # 39383027 –

उत्तर

25

क्षमा दोस्तों, मैं इस सवाल का जवाब मिल गया। मैं सिर्फ UserNotifications ढांचे आयात करने के लिए की जरूरत है।

#import <UserNotifications/UserNotifications.h> 
0

चेक इस

#import <UserNotifications/UserNotifications.h> 

फिर

if (floor(NSFoundationVersionNumber) <= NSFoundationVersionNumber_iOS_9_x_Max) { 
     UIUserNotificationType allNotificationTypes = 
     (UIUserNotificationTypeSound | UIUserNotificationTypeAlert | UIUserNotificationTypeBadge); 
     UIUserNotificationSettings *settings = 
     [UIUserNotificationSettings settingsForTypes:allNotificationTypes categories:nil]; 
     [application registerUserNotificationSettings:settings]; 
    } else { 
     // iOS 10 or later 
#if defined(__IPHONE_10_0) && __IPHONE_OS_VERSION_MAX_ALLOWED >= __IPHONE_10_0 
     // For iOS 10 display notification (sent via APNS) 
     [UNUserNotificationCenter currentNotificationCenter].delegate = self; 
     UNAuthorizationOptions authOptions = 
     UNAuthorizationOptionAlert 
     | UNAuthorizationOptionSound 
     | UNAuthorizationOptionBadge; 
     [[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:authOptions completionHandler:^(BOOL granted, NSError * _Nullable error) { 
     }]; 
#endif 
    } 
संबंधित मुद्दे