2017-09-14 8 views
1

J'utilise la notification UIlocal sur ma réponse du serveur, Quand je cours l'application sur le simulateur montre la notification dans ma zone de notification de l'image envoyée au serveur, mais quand vous exécutez la même application sur le vrai appareil il ne montre rien dans ma zone de notification, le code est bien mais je ne comprends pas pourquoi il ne montre rien, s'il vous plaît aidez-moi. Mon code estUIlocalNotification pas vu dans le vrai périphérique dans IOS

UILocalNotification* localNotification = [[UILocalNotification alloc] init]; 
localNotification.fireDate = res; 
localNotification.alertBody = @"Image Sent"; 
localNotification.timeZone = [NSTimeZone defaultTimeZone]; 
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification]; 

et dans mon dossier AppDelegate.m il est écrit comme cela,

-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{ 
NSLog(@"User Info : %@",notification.request.content.userInfo); 
completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);} 

et quand je lance l'application sur le simulateur, il montre comme ça, mais quand je lance sur réel appareil, il montre rien de tel enter image description here

+0

Avez-vous autorisé les notifications sur votre appareil? –

+0

êtes-vous inscrit au programme de développement des pommes (99 $ par année)? –

+0

oui quand j'ai ouvert la première fois l'application sur mon appareil, il a demandé la permission. @ АлександрКолесник – Oneeb

Répondre

0

Ajouter cette méthode dans appdelegate et l'appeler de didfinishlaunchwithoption

-(void)registerForLocalNotification{ 
    if ([UIApplication instancesRespondToSelector:@selector(registerUserNotificationSettings:)]){ 
     [[UIApplication sharedApplication] registerUserNotificationSettings:[UIUserNotificationSettings 
                 settingsForTypes:UIUserNotificationTypeAlert|UIUserNotificationTypeBadge| 
                 UIUserNotificationTypeSound categories:nil]]; 
    } 
} 
+0

Avez-vous vérifié mon code, j'ai ajouté cela dans mon fichier Appdelegate.m? @KavyaKavita – Oneeb

+0

où? s'il vous plaît vérifier votre question, vous devez avoir posté la moitié du code. Pas capable d'enregistrer registerUserNotificationSettings cette méthode dans votre code – KavyaKavita

+0

ok laissez-moi essayer. @KavyaKavita – Oneeb