我正在开发一个带推送通知的应用,我希望延迟推送通知权限的出现,直到用户第三次进入我的应用程序。所以他应该对我的应用感兴趣,然后我想问他的许可。 我有办法做到这一点吗? 我搜索了很多方法,比如这里: 重置推送应用的通知设置 但我没有得到任何有用的答案。 请帮助。 谢谢
I'm working on an app with push notifications, I want to delay the appearance of the push notifications permission pop up until after the user enters my app for the third time. So he should be interested in my app, then I want to ask him for his permission. I there a way to do that? I searched a lot for a way, like here: Reset push notification settings for app but I didn't get any useful answers. Please Help. Thanks
推荐答案维护一个在中递增的userDefault - (BOOL)应用程序:(UIApplication * )application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {}method
Maintain one userDefault which increments in "- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {}" method
如果userDefault大于3,则寻求Notification的许可
if the userDefault is greater than 3,then seek for permission of Notification
if NSUserDefaults.standardUserDefaults().objectForKey("launchCount")?.integerValue >= 3{ if UIApplication.sharedApplication().respondsToSelector("isRegisteredForRemoteNotifications") { UIApplication.sharedApplication().registerUserNotificationSettings( UIUserNotificationSettings( forTypes: [.Alert, .Badge, .Sound], categories: nil)) UIApplication.sharedApplication().registerForRemoteNotifications() } }更多推荐
如何延迟推送通知权限弹出Swift
发布评论