expo-pusher-push-notifications 0.4.1 → 0.4.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -25,7 +25,7 @@ await Interests.start('YOUR_BEAMS_INSTANCE_ID');
25
25
  await Interests.subscribe('news');
26
26
  ```
27
27
 
28
- That device now gets anything your server publishes to `news`. Full console steps (APNs, Firebase, Beams) are in [Setup](docs/setup.md).
28
+ That device now gets pushes sent to `news`. Full console steps (APNs, Firebase, Beams) are in [Setup](docs/setup.md).
29
29
 
30
30
  ## Subscribe to interests (topics)
31
31
 
@@ -40,16 +40,16 @@ More in [Interests](docs/interests.md).
40
40
 
41
41
  ## Bind a device to a user
42
42
 
43
- When your backend thinks in user ids ("send this to user-123"), bind the device to the signed-in user. Beams asks your API for an auth token, so you need one small endpoint on your server.
43
+ To get pushes meant for a specific signed-in user on all their devices, bind the device to that user.
44
44
 
45
45
  ```ts
46
46
  import { Users } from 'expo-pusher-push-notifications';
47
47
 
48
48
  await Users.start('YOUR_BEAMS_INSTANCE_ID');
49
49
 
50
- // after your own sign-in
50
+ // after your own sign-in (url = your Beams token provider)
51
51
  await Users.login('user-123', {
52
- url: 'https://api.example.com/pusher/beams-auth',
52
+ url: 'YOUR_BEAMS_TOKEN_URL',
53
53
  headers: { Authorization: `Bearer ${sessionToken}` },
54
54
  });
55
55
 
@@ -57,17 +57,7 @@ await Users.login('user-123', {
57
57
  await Users.logout();
58
58
  ```
59
59
 
60
- You can use interests and users together. See [Authenticate users](docs/users.md) for the server side.
61
-
62
- ## Send from your server
63
-
64
- ```js
65
- import PushNotifications from '@pusher/push-notifications-server';
66
- const beams = new PushNotifications({ instanceId, secretKey });
67
-
68
- await beams.publishToInterests(['news'], payload); // everyone on a topic
69
- await beams.publishToUsers(['user-123'], payload); // one user, all their devices
70
- ```
60
+ You can use interests and users together. More in [Users](docs/users.md).
71
61
 
72
62
  ## Extras
73
63
 
@@ -86,7 +76,7 @@ Custom sounds go in the plugin's `sounds` option. Details in [Extras](docs/extra
86
76
 
87
77
  - [Setup](docs/setup.md)
88
78
  - [Interests](docs/interests.md)
89
- - [Authenticate users](docs/users.md)
79
+ - [Users](docs/users.md)
90
80
  - [Sounds, channels, badges, local notifications](docs/extras.md)
91
81
  - [Full API](docs/api.md)
92
82
  - [Migrating from react-native-pusher-push-notifications](docs/migrating.md)
package/docs/extras.md CHANGED
@@ -29,7 +29,7 @@ await Push.setBadgeCount(0); // clear
29
29
 
30
30
  - **iOS:** uses the real app icon badge (`UNUserNotificationCenter.setBadgeCount`). Payloads can also set `aps.badge`.
31
31
  - **Android:** there is no system badge API. The module keeps a counter, applies it as the notification number on notifications it posts, and clears the shade when you set the count to `0`. Launchers show dots or counts based on the channel's `showBadge` setting.
32
- - **`incrementBadge` (from b8ne):** add `"incrementBadge": true` under `aps.data` or a top-level `data` (iOS), or `"incrementBadge": "true"` in FCM `data` (Android), and the badge goes up by one on the device. Your backend doesn't need to track counts.
32
+ - **`incrementBadge` (from b8ne):** add `"incrementBadge": true` under `aps.data` or a top-level `data` (iOS), or `"incrementBadge": "true"` in FCM `data` (Android), and the badge goes up by one on the device.
33
33
 
34
34
  ## Local notifications
35
35
 
package/docs/interests.md CHANGED
@@ -1,7 +1,6 @@
1
1
  # Interests (topics)
2
2
 
3
3
  Use interests when many devices should get the same push. Think topics: `news`, `order-42`, `team-7`.
4
- You need a Pusher Beams instance. Your server calls `publishToInterests`.
5
4
 
6
5
  ## Client
7
6
 
@@ -20,18 +19,6 @@ await Interests.clear();
20
19
  await Interests.reset();
21
20
  ```
22
21
 
23
- ## Server (Node)
24
-
25
- ```js
26
- import PushNotifications from '@pusher/push-notifications-server';
27
- const beams = new PushNotifications({ instanceId, secretKey });
28
-
29
- await beams.publishToInterests(['news'], {
30
- apns: { aps: { alert: { title: 'Hi', body: 'News!' }, sound: 'ding.wav', badge: 3 } },
31
- fcm: { notification: { title: 'Hi', body: 'News!', sound: 'ding', android_channel_id: 'messages' } },
32
- });
33
- ```
34
-
35
22
  ## API
36
23
 
37
24
  | Call | What it does |
package/docs/migrating.md CHANGED
@@ -21,7 +21,7 @@ Neither original had custom sounds, notification channels, or local and schedule
21
21
 
22
22
  ## Coming from 0.3
23
23
 
24
- 0.4 removes raw device-token support (`DeviceToken`, `registerForDeviceToken`, `getDevicePushToken`, `deleteDevicePushToken`, and `mode: 'device'`). This package is Pusher Beams only now. If you need a raw FCM / APNs token for your own server, use [`expo-notifications`](https://docs.expo.dev/versions/latest/sdk/notifications/) and `getDevicePushTokenAsync()` instead.
24
+ 0.4 removes raw device-token support (`DeviceToken`, `registerForDeviceToken`, `getDevicePushToken`, `deleteDevicePushToken`, and `mode: 'device'`). This package is Pusher Beams only now. If you need a raw FCM / APNs token, use [`expo-notifications`](https://docs.expo.dev/versions/latest/sdk/notifications/) and `getDevicePushTokenAsync()` instead.
25
25
 
26
26
  ## Steps
27
27
 
package/docs/setup.md CHANGED
@@ -52,7 +52,6 @@ The plugin also adds the `remote-notification` background mode on iOS. On Androi
52
52
  1. **iOS:** enable the Push Notifications capability. The plugin sets the entitlement. Create an APNs auth key (.p8).
53
53
  2. **Android:** create a Firebase project, download `google-services.json`, and point `android.googleServicesFile` at it.
54
54
  3. **Beams:** create a Beams instance in the [Pusher dashboard](https://dashboard.pusher.com/beams), then upload your APNs key and your FCM service account to it.
55
- 4. **If you bind devices to users:** add an authenticated endpoint to your backend that returns `{ "token": beamsClient.generateToken(userId) }` (see the [Beams auth docs](https://pusher.com/docs/beams/guides/publish-to-specific-user/)).
56
55
 
57
56
  ## Permissions
58
57
 
package/docs/users.md CHANGED
@@ -1,8 +1,6 @@
1
1
  # Bind a device to a user
2
2
 
3
- When your backend thinks in user ids ("send this to user-123"), bind the device to the signed-in user and Beams will deliver to every device they're signed in on.
4
-
5
- How it works: after your own sign-in, the app calls `Users.login(userId, …)`. Beams then asks **your API** for a short-lived auth token, which proves this user really is `user-123`. So you need one authenticated endpoint on your server.
3
+ Bind the device to the signed-in user so pushes for that user reach every device they're signed in on. Call `Users.login` after your own sign-in, and `Users.logout` on sign-out.
6
4
 
7
5
  ## In the app
8
6
 
@@ -11,9 +9,9 @@ import { Users } from 'expo-pusher-push-notifications';
11
9
 
12
10
  await Users.start('YOUR_BEAMS_INSTANCE_ID');
13
11
 
14
- // After your own sign-in. Beams calls this URL and refreshes the token for you.
12
+ // After your own sign-in. Pass your Beams token provider URL (and headers, if it needs them).
15
13
  await Users.login('user-123', {
16
- url: 'https://api.example.com/pusher/beams-auth',
14
+ url: 'YOUR_BEAMS_TOKEN_URL',
17
15
  headers: { Authorization: `Bearer ${sessionToken}` },
18
16
  });
19
17
 
@@ -24,23 +22,6 @@ await Users.login('user-123', beamsToken);
24
22
  await Users.logout();
25
23
  ```
26
24
 
27
- ## On your server (Node)
28
-
29
- ```js
30
- // GET /pusher/beams-auth (must be authenticated, and user_id must match the session)
31
- app.get('/pusher/beams-auth', requireSession, (req, res) => {
32
- res.json(beams.generateToken(req.user.id)); // { token: '…' }
33
- });
34
-
35
- // Send
36
- await beams.publishToUsers(['user-123'], {
37
- apns: { aps: { alert: { title: 'Hey', body: 'You have a new message' }, sound: 'ding.wav' } },
38
- fcm: { notification: { title: 'Hey', body: 'You have a new message', android_channel_id: 'messages' } },
39
- });
40
- ```
41
-
42
- See Pusher's [auth guide](https://pusher.com/docs/beams/guides/publish-to-specific-user/).
43
-
44
25
  ## API
45
26
 
46
27
  | Call | What it does |
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-pusher-push-notifications",
3
- "version": "0.4.1",
3
+ "version": "0.4.2",
4
4
  "description": "Pusher Beams push notifications for Expo (interests and authenticated users), with custom sounds, Android channels, badges and local notifications",
5
5
  "main": "build/index.js",
6
6
  "types": "build/index.d.ts",