Boo*_*nge 5 xcode info.plist root.plist ios swift
解释我想要存档的最好方法是使用 Facebook iOS 应用截图:
单击该按钮会将用户直接重定向到 Facebook 应用程序(通知设置)。
我只能向根设置窗口添加一些开关和标签(通过使用 Settings.bundle。
那么如何将用户从我的应用通知设置重定向到我的应用?
在此先感谢您的帮助。
小智 11
您应该使用 UNUserNotificationCenter 并请求授权.providesAppNotificationSettings
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .alert, .sound, .providesAppNotificationSettings])
Run Code Online (Sandbox Code Playgroud)
然后使用UNUserNotificationCenterDelegate方法进行处理:
func userNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification?) {
// Open settings view controller
}
Run Code Online (Sandbox Code Playgroud)
@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {
func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
// Override point for customization after application launch.
UNUserNotificationCenter.current().delegate = self
UNUserNotificationCenter.current().requestAuthorization(options: [.badge, .alert, .sound, .providesAppNotificationSettings])
return true
}
func userNotificationCenter(_ center: UNUserNotificationCenter, openSettingsFor notification: UNNotification?) {
// Open settings view controller
}
}
Run Code Online (Sandbox Code Playgroud)
@interface TAXAppDelegate : UIResponder <UIApplicationDelegate, UNUserNotificationCenterDelegate>
////
@end
@implementation TAXAppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
{
[[UNUserNotificationCenter currentNotificationCenter] setDelegate:self];
[[UNUserNotificationCenter currentNotificationCenter] requestAuthorizationWithOptions:(UNAuthorizationOptionBadge | UNAuthorizationOptionSound | UNAuthorizationOptionAlert | UNAuthorizationOptionProvidesAppNotificationSettings) completionHandler:^(BOOL granted, NSError * _Nullable error) {
if (granted) {
///
}
}];
return YES;
}
- (void)userNotificationCenter:(UNUserNotificationCenter *)center openSettingsForNotification:(UNNotification *)notification
{
// Open settings view controller
}
@end
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
940 次 |
| 最近记录: |