urbanairship / ios-library

Urban Airship iOS SDK
http://urbanairship.com
Apache License 2.0
478 stars 265 forks source link

didRegisterUserNotificationSettings not called iOS 8 #130

Closed petarbelokonski closed 7 years ago

petarbelokonski commented 7 years ago

Bumping an old thread

didRegisterUserNotificationSettings is not deprecated in iOS 10 as explained in the mentioned thread.

How to get a callback when the user has acted on the system dialog ? Regardless of whether they choose "Don't allow" or "Allow ?

RE: https://github.com/urbanairship/ios-library/issues/112

rlepinski commented 7 years ago

@petarbelokonski Hmm, you are right that apple did not actually deprecate those methods. However they did UIUserNotificationSettings in favor of the new UNUserNotificaitonCenter calls. In order to trigger didRegisterUserNotificationSettings: you have to call registerUserNotificationSettings: with the deprecated class, so effectively that registration path is deprecated.

Our SDK calls the new UNUserNotificaitonCenter for iOS 10, so you will not get a call to didRegisterUserNotificationSettings:. We do provide several registration method callbacks that might be useful to you in our UAPushRegistrationDelegate. Specifically notificationRegistrationFinishedWithOptions:categories and notificationAuthorizedOptionsDidChange: should be good replacements for didRegisterUserNotificationSettings: and they work across OS versions.

You should assign the push registration delegate immediately after takeOff:

// Swift
UAirship.push().registrationDelegate = customDelegate

// Obj-C
[UAirship push].registrationDelegate = customDelegate;
rlepinski commented 7 years ago
NS_CLASS_DEPRECATED_IOS(8_0, 10_0, "Use UserNotifications Framework's UNNotificationSettings") __TVOS_PROHIBITED
@interface UIUserNotificationSettings : NSObject

from UIUserNotificationSettings.h

petarbelokonski commented 7 years ago

@rlepinski thanks for your clarification.

At the moment I am having this implementation :

   func application(_ application: UIApplication, didRegister notificationSettings: UIUserNotificationSettings) {
        if notificationSettings.types.isEmpty {
            print("user tapped don't allow button")
        } else {
            print("user tapped allow button ")
        }
    }

Basically the idea is that I want to track which button the user has tapped. Can you please confirm that I can achieve the same result using the notificationRegistrationFinishedWithOptions:categories callback of UAPushRegistrationDelegate. Many thanks !