在应用商店中提交应用时本地通知不起作用
Posted
技术标签:
【中文标题】在应用商店中提交应用时本地通知不起作用【英文标题】:Local Notification not working when submit app in app store 【发布时间】:2017-02-08 15:28:39 【问题描述】:当我为我的应用程序提交更新时,本地通知不起作用。我已经在我的设备上进行了测试,它可以正常工作,但是当我从 AppStore 下载应用程序时,通知根本不起作用 这里的代码是 AppDelgate :
class AppDelegate: UIResponder, UIApplicationDelegate,UNUserNotificationCenterDelegate
@available(ios 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, didReceive response: UNNotificationResponse, withCompletionHandler completionHandler: @escaping () -> Void)
@available(iOS 10.0, *)
func userNotificationCenter(_ center: UNUserNotificationCenter, willPresent notification: UNNotification, withCompletionHandler completionHandler: @escaping (UNNotificationPresentationOptions) -> Void)
completionHandler([.alert,.sound])
并且我已经实现了这段代码,以便在计时器命中发布日期时发送通知
import UserNotifications
let center = UNUserNotificationCenter.current()
let options : UNAuthorizationOptions = [.alert, .sound, .badge]
center.requestAuthorization(options: options) (granted, error) in
if !granted
print("Somthing went wrong")
center.getNotificationSettings (settings) in
if settings.authorizationStatus != .authorized
print("Notification not allowd")
here is in different function that calculate the time and send notification, I have not put the code for timer to make it more visual for others
let content = UNMutableNotificationContent()
content.title = NSLocalizedString("NOTIFICATION_TITLE", comment: "Game Released")
content.body = "\(self.currentGame.gameName) Released ✌????"
content.sound = UNNotificationSound.default()
let date = dateFormatter.date(from: currentGame.gameDate)
let triggerDate = Calendar.current.dateComponents([.year,.month,.day,.hour,.minute,.second], from: date!)
let trigger = UNCalendarNotificationTrigger(dateMatching: triggerDate, repeats: false)
let indetifier = "UYLLocalNotification"
let request = UNNotificationRequest(identifier: indetifier, content: content, trigger: trigger)
center.add(request, withCompletionHandler: (error) in
if error != nil
print("Something went wrong here ")
)
else
gamesCountdownLabel.text! = countdownText
我希望有人可以帮助我我已经尝试了所有解决方案,但除了我的开发设备外,仍然没有为用户工作
【问题讨论】:
请让我们知道究竟发生了什么“根本不工作”以及工作和非工作设备正在运行的 iOS 版本。 @shallowThought 根本不起作用,所有版本都包括 ios 10 任何人都可以帮助解决这个问题 【参考方案1】:通知委托问题 并检查通知的时间和日期
【讨论】:
以上是关于在应用商店中提交应用时本地通知不起作用的主要内容,如果未能解决你的问题,请参考以下文章
Flutter 本地通知 - 当应用程序在后台运行时,ZonedSchedule 通知不起作用