New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
New PushKit delegate method for iOS 11 #128
New PushKit delegate method for iOS 11 #128
Conversation
@@ -167,14 +167,31 @@ class ViewController: UIViewController, PKPushRegistryDelegate, TVONotificationD | |||
self.deviceTokenString = nil | |||
} | |||
|
|||
/** |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this might be a copy/paste error of the comment.
@@ -180,6 +180,10 @@ class ViewController: UIViewController, PKPushRegistryDelegate, TVONotificationD | |||
self.deviceTokenString = nil | |||
} | |||
|
|||
/** | |||
* Try using the `pushRegistry:didReceiveIncomingPushWithPayload:forType:withCompletionHandler:` method if | |||
* your application is targeting iOS 11. This delegate method wil soon be deprecated by Apple. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This delegate method is deprecated by Apple.
According to the docs.
@@ -188,6 +192,19 @@ class ViewController: UIViewController, PKPushRegistryDelegate, TVONotificationD | |||
} | |||
} | |||
|
|||
/** | |||
* This is delegate method is available in iOS 11 and above. Call the completion handler once the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This delegate method is available on iOS 11 and above.
@@ -188,6 +192,19 @@ class ViewController: UIViewController, PKPushRegistryDelegate, TVONotificationD | |||
} | |||
} | |||
|
|||
/** | |||
* This is delegate method is available on iOS 11 and above. Call the completion handler once the |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This delegate
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I just had a comment about Swift idioms. It would be nice to adopt print
instead of NSLog
but this can be done in another PR if you wish.
* notification payload is passed to the `TwilioVoice.handleNotification()` method. | ||
*/ | ||
func pushRegistry(_ registry: PKPushRegistry, didReceiveIncomingPushWith payload: PKPushPayload, for type: PKPushType, completion: @escaping () -> Void) { | ||
NSLog("pushRegistry:didReceiveIncomingPushWithPayload:forType:completion:") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
General Swift style comment, should't we use print("pushRegistry:didReceiveIncomingPushWithPayload:forType:completion:")
instead?
The
pushRegistry:didReceiveIncomingPushWithPayload:forType:withCompletionHandler:
is available on iOS 11 and above. The originalpushRegistry:didReceiveIncomingPushWithPayload:forType:
will soon be deprecated by Apple.The
pushRegistry:didReceiveIncomingPushWithPayload:forType:withCompletionHandler:
method will be called if both the methods exist.Note: calling the
TwilioVoice.handleNotification()
method is guaranteed to get at least one of theTVONotificationDelegate
callback immediately, so it is safe to call the completion handler right after callingTwilioVoice.handleNotification()
.