This app gives you a brief understanding of how Ably's Push Notifications work. You will need a real iOS device to test this functionality.
- First, go to https://ably.com/accounts/, create an app and copy API key from API Keys tab of the app's dashboard.
- Go to the
Notifications
tab of the Ably's app dashboard and scroll to thePush Notifications Setup
section. PressConfigure Push
and follow the instructions there. - Insert it instead of an empty string in the
key
property's value inside theAblyHelper
class. - Make sure you've selected your development team in the
Signing & Capabilities
tab of the Xcode project target settings and all the provisioning profiles created without errors (update thebundle-id
for theAblyPushExample
target as needed). - Build and Run the app on your device.
- Hit "Activate Push" button, then hit "Print Token". You should see "IDENTITY TOKEN: exists" printed in the debug output window.
- Hit "Device Details" to display Ably push device registration info after successful activation.
- Go to the
Notifications
tab of the Ably's app dashboard again and scroll to thePush Inspector
section. Fill inTitle
andBody
fields of the push notification. Then insert "basic-apns-example" in theClient ID
field and press enter. Then hit "Push to client" button. You should now see the notification on the screen of your device. - Also you can send notifications from the app itself if you tick
Push Admin
capability in your API key settings in the app's dashboard. Just hit "Send Push to deviceId" button to send a predefined push notification which is also will be displayed on your device's screen right away. You can change this behavior in theUNUserNotificationCenterDelegate
extension for theAblyHelper
by editingcompletionHandler([.banner, .sound])
line of code. - To test Channels based push, go to the
Settings
tab of the Ably dashboard and scroll down toChannel rules
. PressAdd new rule
and name your channel IDexampleChannel1
, tickPush notifications enabled
before scrolling down and pressingCreate channel rule
. Repeat this step for a channel namedexampleChannel2
. You can now subscribe and send pushes to these two channels within the example app. You can also use the Push Inspector.
-
In order to use this capability (starting from iOS 15), you need to apply for the special entitlement on the Apple's developer portal. Follow instructions here on how to do that.
-
Select
AblyPushExampleLP
scheme to build the version of the example, that utilizes location push service extension. -
Update the
bundle-id
for theAblyPushExample
,AblyPushExampleLP
andAblyLocationPush
targets as needed (keepAblyLocationPush
suffix for the latter). Find your app'sApp ID
on the development portal and enableLocation Push Service Extension
setting in theAdditional Capabilities
tab. Make sure both your app's identifier and location push extension's identifier use the sameApp Group
. This example usesAutomatically manage signing
, so all those identifiers are created for you by Xcode withXC
prefix in their display name. -
Use the "Location push events" button in the example app to open a list of received location push notifications.