I have a permissions framework in Swift that needs a push notification permission delegate callback. The push notification callback resides in the App Delegate, so my framework won't have access to each app's delegate. I'm thinking I could use method swizzling to intercept the methods (i.e. didRegisterForRemoteNotificationsWithDeviceToken
).
To test, I have:
let method1 = class_getInstanceMethod(UIApplication.shared.delegate as! AnyClass!, Selector.init(stringLiteral: "applicationWillEnterForeground:"))
let method2 = class_getInstanceMethod(self.classForCoder, Selector.init(stringLiteral: "testerFunc"))
if let method1 = method1, let method2 = method2 {
method_exchangeImplementations(method1, method2)
}
Any ideas?