Skip to content
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

Merged

Conversation

bobiechen-twilio
Copy link
Contributor

The pushRegistry:didReceiveIncomingPushWithPayload:forType:withCompletionHandler: is available on iOS 11 and above. The original pushRegistry: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 the TVONotificationDelegate callback immediately, so it is safe to call the completion handler right after calling TwilioVoice.handleNotification().

@@ -167,14 +167,31 @@ class ViewController: UIViewController, PKPushRegistryDelegate, TVONotificationD
self.deviceTokenString = nil
}

/**
Copy link
Contributor

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.
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This delegate

Copy link
Contributor

@ceaglest ceaglest left a 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:")
Copy link
Contributor

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?

@bobiechen-twilio bobiechen-twilio merged commit 3e2a471 into twilio:master May 15, 2018
@bobiechen-twilio bobiechen-twilio deleted the new-pushkit-delegate-method branch July 5, 2018 23:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants