Load webView after clicking enable on SWIFT 3

1

I have a webview that captures the device token using the firebase library and then sends it to my url via get. Until then, I was able to get the token, and I can send it to the url and in the back end I already enter the database, td quietly, the problem I am having is the first time the application is opened after it is installed it requests my permission to receive notifications, however with this I can not send the token to the url because the same ñ is generated. Is there any way to call a function after I click enable?

    
asked by anonymous 25.01.2017 / 15:04

1 answer

0

If the user allows you to receive notifications, you will receive a callback in your AppDelegate, you should implement your code in the following method:

func application(_ application: UIApplication, didRegisterForRemoteNotificationsWithDeviceToken deviceToken: Data)
{
    // insira seu código aqui
}

If the user does not allow receiving notifications, then called method will be:

func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error)
{
    // insira seu código aqui
}

You can read more about the methods in the documentation: UIApplicationDelegate

    
18.02.2017 / 10:11