How to control when to prompt user for push notification permissions in iOS

后端 未结 3 771
伪装坚强ぢ
伪装坚强ぢ 2021-02-13 19:05

I\'ve built an application for iPhone using Swift and Xcode 6, and the Parse framework to handle services.

While following the Parse tutorials on how to set up push noti

3条回答
  •  余生分开走
    2021-02-13 19:55

    The answer is simple. If you want the user to be prompted some other time, for instance on a button press then simply move the code regarding the request into that function (or call promptUserToRegisterPushNotifications() from somewhere else).

    To get a hold of the application variable outside the AppDelegate, simply do this:

    let application = UIApplication.shared
    

    Hope that helps :)

提交回复
热议问题