Local Notifications make sound but do not display (Swift)

前端 未结 3 923
死守一世寂寞
死守一世寂寞 2021-01-13 10:38

I am trying to create a local notification for my app using Apple\'s UNUserNotificationCenter.

Here is my code:

let center = UNUserNotificationCenter         


        
3条回答
  •  孤城傲影
    2021-01-13 10:44

    Add this code into didFinishLaunchingWithOption in AppDelegate.swift file

    let center = UNUserNotificationCenter.current()
    center.requestAuthorization(options: [.alert, .sound]) 
    { (granted, error) in
    // Enable or disable features based on authorization.
    }
    

提交回复
热议问题