You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
fix(push-guides): restructure APNs, FCM, and web push guides to match react-native/flutter layout
- Add Step 5 "Publish a push notification" with CLI-only publish (client-id + channel sub-steps)
- Remove send-with-code examples from all three guides
- Remove push-admin Aside (info already in prerequisites)
- Align Step 3 opening text across all guides
- Update "send push notifications" to "publish push notifications" throughout
- Restore service worker description sentence in web guide
- APNs Step 6 (location pushes) renumbered from Step 7 after removing send-with-code step
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This guide will get you started with Ably Push Notifications in a new SwiftUI application.
8
8
9
-
You'll learn how to set up your `AppDelegate` to manage push notifications, register devices with Ably, send push notifications, subscribe to channel-based push, handle incoming notifications, and implement location-based push notifications.
9
+
You'll learn how to set up your `AppDelegate` to manage push notifications, register devices with Ably, publish push notifications, subscribe to channel-based push, handle incoming notifications, and implement location-based push notifications.
10
10
11
11
<Asidedata-type='note'>
12
12
Using an AI coding assistant? [Teach it Ably](/docs/platform/ai-llms#agent-skills) with Agent Skills for all popular AI coding agents. Run `claude plugin add ably/agent-skills` or `npx skills add ably/agent-skills` to get started.
@@ -16,16 +16,16 @@ Using an AI coding assistant? [Teach it Ably](/docs/platform/ai-llms#agent-skill
16
16
17
17
1.[Sign up](https://ably.com/signup) for an Ably account.
18
18
2. Create a [new app](https://ably.com/accounts/any/apps/new), and create your first API key in the **API Keys** tab of the dashboard.
19
-
3.Your API key will need the `publish` and `subscribe` capabilities. For sending push notifications from your app, you'll also need the `push-admin` capability.
20
-
4. For channel-based push, add a rule for the channel with **Push notifications enabled** checked. In the dashboard left sidebar: **Configuration** → **Rules** → **Add** or **Edit** a rule,
21
-
then enable the Push notifications option. See [rules](/docs/channels#rules) for details.
6. You'll need a real iOS device to test push notifications (the simulator doesn't support APNs).
24
-
7. Set up Apple Push Notification service (APNs) certificates through the [Apple Developer Portal](https://developer.apple.com/).
19
+
*Your API key needs the `publish` and `subscribe` capabilities.
20
+
* Also add the `push-admin` capability if you're using the same API key to publish a push notification. In production this would more likely be a server using a different API key.
21
+
3. Add a rule to a channel so you can test sending push notifications via a channel. Select [**Rules**](https://ably.com/accounts/any/apps/any/app_namespaces) in the Ably dashboard, add a new rule and enable the **Push notifications** option.
Sending push notifications using `deviceId` or `clientId` requires the `push-admin` capability for your API key. Use this method for testing purposes. In a production environment, you would typically send push notifications from your backend server (by posting messages with `push``extras` field to a channel).
278
-
279
-
To test push notifications in your app, you can use [Ably dashboard](https://ably.com/dashboard), [Apple developer dashboard](https://icloud.developer.apple.com/dashboard/) or [Ably CLI](/docs/platform/tools/cli).
280
-
281
-
To publish to your client ID using the [Ably CLI](/docs/platform/tools/cli) paste the following command into your terminal:
Build and run your app in Xcode on a real device. You will see the UI with sections to activate
549
-
push notifications and subscribe to channels. Tap the "Activate Push" button and wait until the status message
550
-
displays the received device token. Try sending push using client ID or device ID as shown earlier.
551
-
You can get your device ID from the device details button (don't confuse it with the device token):
552
-
553
-

533
+
push notifications and subscribe to channels.
554
534
555
-
### Send push via channel <aid="step-4-send-channel"/>
556
-
557
-
To test pushes via channel, subscribe to "Channel 1" in the UI and publish a push notification to the channel using the [Ably CLI](/docs/platform/tools/cli):
Tap **Activate Push** and wait until the status message displays the received device token. You can get your device ID from the **Get Device Details** button (don't confuse it with the device token).
604
538
605
-
/// Send push notification to a specific client ID
### Publish directly to your device <aid="step-5-direct"/>
626
540
627
-
Sending to a channel is just publishing a message on a channel with a `push``extras` field:
541
+
Publish a push notification directly to your client ID (or device ID using `--device-id` instead of `--client-id`) via the [Ably CLI](/docs/platform/tools/cli):
628
542
629
-
<Code>
630
-
```swift
631
-
/// Send push notification to a specific channel by publishing a message with a push extras field
632
-
funcsendPushToChannel(_channelName: String) {
633
-
let message =ARTMessage(name: "example", data: "Hello from channel!")
634
-
message.extras= [
635
-
"push": [
636
-
"notification": [
637
-
"title":"Channel Push",
638
-
"body":"Sent push to \(channelName)"
639
-
],
640
-
"data": [
641
-
"foo":"bar",
642
-
"baz":"qux"
643
-
]
644
-
]
645
-
] asany ARTJsonCompatible
646
-
647
-
realtime.channels.get(channelName).publish([message]) { error in
648
-
iflet error {
649
-
print("Error sending push to \(channelName) with error: \(error.localizedDescription)")
If you unsubscribe from this channel in the app's UI, you will no longer receive push notifications for that channel. Run the same command again and verify that no notification is received.
758
568
759
-
Build and run your app again. Use the added section to send push notifications.
569
+
To see the full list of options for publishing push notifications with the Ably CLI, run `ably push publish --help` or see the [Ably CLI push documentation](/docs/cli/push). To publish push notifications from your own server code instead of the CLI, see [Push notification publishing](https://ably.com/docs/push/publish).
760
570
761
571
## Step 6: Location pushes <aid="step-6"/>
762
572
@@ -769,7 +579,7 @@ Add `Location (when in use)`, `Location (Always)`, `Location Push Service Extens
769
579
Add `Location Push Service Extension` target as described at the [Apple Developer Portal](https://developer.apple.com/documentation/CoreLocation/creating-a-location-push-service-extension).
770
580
For simplicity, use **Automatically manage signing**, so all needed identifiers are created for you by
771
581
Xcode (with XC prefix in their display name). Your Location Push Service Extension should have a bundle
772
-
identifier of your app with a suffix of extension's product name (e.g., `the.company.TheApp.TheExtension`).
582
+
identifier of your app with a suffix of extension's product name (for example, `the.company.TheApp.TheExtension`).
0 commit comments