【发布时间】:2017-09-14 18:11:26
【问题描述】:
我在来自服务器的响应中使用 UIlocal 通知,当我在模拟器上运行应用程序时,它会在发送到服务器的图像的通知区域中显示通知,但是当您在真实设备上运行相同的应用程序时,它在我的通知区域中不显示任何内容,代码很好,但我不明白为什么它没有显示任何内容,请帮助我。 我的代码是,
UILocalNotification* localNotification = [[UILocalNotification alloc] init];
localNotification.fireDate = res;
localNotification.alertBody = @"Image Sent";
localNotification.timeZone = [NSTimeZone defaultTimeZone];
[[UIApplication sharedApplication] scheduleLocalNotification:localNotification];
在我的 AppDelegate.m 文件中是这样写的,
-(void)userNotificationCenter:(UNUserNotificationCenter *)center willPresentNotification:(UNNotification *)notification withCompletionHandler:(void (^)(UNNotificationPresentationOptions options))completionHandler{
NSLog(@"User Info : %@",notification.request.content.userInfo);
completionHandler(UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionBadge);}
【问题讨论】:
-
您是否允许在您的设备上发送通知?
-
您是否加入了苹果开发者计划(每年 99 美元)?
-
是的,当我第一次在我的设备上打开应用程序时,它会请求许可。 @АлександрКолесник
-
没有。 @MohammadBashirSidani
-
尝试在功能中启用后台模式
标签: ios objective-c uilocalnotification