我构建了IOS应用程序,并在其上使用了推送通知。当我的应用程序状态为后台或前景时,推送通知单击工作正常,但是当状态被终止时,我单击通知应用程序崩溃,并且由于应用程序已处于终止状态,我无法看到日志。是什么原因?
我在AppDelegate中使用以下代码:
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
notificaionsCount = "\(UIApplication.shared.applicationIconBadgeNumber)"
FirebaseApp.configure()
Fabric.with([Crashlytics.self])
brainClient = BTAPIClient.init(authorization: ProjectSingletenClass.shared.clientTokenOrTokenizationKey)
BTUIKAppearance.darkTheme()
UNUserNotificationCenter.current().delegate = self
IQKeyboardManager.sharedManager().enable = true
STPPaymentConfiguration.shared().publishableKey = ProjectSingletenClass.shared.publishableKeyForStripe
sinchManagedPush = Sinch.managedPush(with: SINAPSEnvironment.development)
sinchManagedPush?.delegate = self
sinchManagedPush?.setDesiredPushTypeAutomatically()
sinchManagedPush?.registerUserNotificationSettings()
let dispatch_Queue : DispatchQueue? = DispatchQueue.init(label: "Latter")
pushRegistry = PKPushRegistry.init(queue: dispatch_Queue)
pushRegistry.delegate = self
//let pushTypeSet : Set<PKPushType>?
pushRegistry.desiredPushTypes = NSSet.init(object: PKPushType.voIP) as? Set<PKPushType>
NotificationCenter.default.addObserver(self,
selector: #selector(tokenRefreshNotification(_:)),
name: NSNotification.Name.InstanceIDTokenRefresh,
object: nil)
registerForPushNotifications(application)
SVProgressHUD.setBackgroundColor(UIColor.cherryRed)
return true
}