0

I am developing a Cocoa Touch Framework, I want to receive remote notifications from APNS and I found that (after all the process it needs to establish communication with APNS) I have to catch notifications inside application:didReceiveRemoteNotification:fetchCompletionHandler: method. However, I want to let the less work possible to the IOS developer, so I been wondering.

  • Is it possible to create a category of the AppDelegate inside my framework (Since it already has an extension when a new app is created) in order to implement this method ?.

1 Answer 1

1

I would say it's not needed. What you can do here is create some function in your with the same params as in application:didReceiveRemoteNotification:fetchCompletionHandler: and make it available for the possible developer to call from your Framework.

Many frameworks are working that way like FacebookSDK. For example, my code in AppDelegate for opening/handling URL:

func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
    let fbHandled: Bool = ApplicationDelegate.shared.application(app,
                                                               open: url,
                                                               sourceApplication: options[.sourceApplication] as? String,
                                                               annotation: options[.annotation])
    return fbHandled
}

You could see that Facebook just provide me some public methods to handle links inside their SDK. It's a better solution than make implicit handling for something that the developer might be needed aware of and be available to change in his code.

1
  • I did not took that aproach in consideration, I really appreciate it.
    – Rafael
    Oct 21, 2019 at 19:25

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.