Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/swift/19.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Ios 从其他应用程序委托函数调用didRegisterUserNotificationSettings_Ios_Swift_Appdelegate - Fatal编程技术网

Ios 从其他应用程序委托函数调用didRegisterUserNotificationSettings

Ios 从其他应用程序委托函数调用didRegisterUserNotificationSettings,ios,swift,appdelegate,Ios,Swift,Appdelegate,我正在向我的应用程序添加入职指南,并希望要求用户在指南的特定幻灯片上注册通知。我想知道是否有办法从我的入职函数调用didRegisterUserNotificationSettings函数。如果我不能直接调用它,有没有办法创建一个不同的函数来执行相同的功能,并且可以由我的入职函数调用 编辑我刚刚添加 let notificationType = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotific

我正在向我的应用程序添加入职指南,并希望要求用户在指南的特定幻灯片上注册通知。我想知道是否有办法从我的入职函数调用didRegisterUserNotificationSettings函数。如果我不能直接调用它,有没有办法创建一个不同的函数来执行相同的功能,并且可以由我的入职函数调用

编辑我刚刚添加

 let notificationType = UIUserNotificationType.Alert | UIUserNotificationType.Badge | UIUserNotificationType.Sound
        let settings = UIUserNotificationSettings(forTypes: notificationType, categories: nil)
        UIApplication.registerUserNotificationSettings(settings)
我现在得到以下错误

Uiusernotificationsettings不能转换为uiapplication


是的,有。当您在“指南的特定幻灯片”中时,请调用注册表通知类型:

但是,弹出窗口只出现一次。如果用户禁用了你的应用程序的通知,你最多可以给他一个选项,让他进入设置页面,在那里他应该手动启用它。(一定不要让他太生气。)

请注意,调用
didRegisterUserNotificationSettings:
是没有用的,因为它是一个委托方法,在您的应用程序成功注册通知时调用

编辑

这是你应该注册的方式

UIApplication.sharedApplication().registerUserNotificationSettings(settings)
UIApplication.sharedApplication().registerForRemoteNotifications()

我刚刚对幻灯片进行了更改(请参见编辑),但是我收到了一个错误。不要怀疑,确实如此,但我不确定如何处理该错误