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
Maintain one userDefault which increments in "- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {}" method
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()
        }
    }
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With