expo-pusher-push-notifications 0.4.0 → 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
@@ -1,23 +1,22 @@
1
1
  # expo-pusher-push-notifications
2
2
 
3
- Pusher Beams push notifications for Expo (SDK 58+). Custom sounds included.
3
+ Push notifications for Expo and React Native, powered by [Pusher Beams](https://pusher.com/beams). Subscribe devices to topics, bind them to your signed-in users, and get custom sounds, Android channels, badges, and local notifications along the way.
4
4
 
5
5
  ```sh
6
6
  npx expo install expo-pusher-push-notifications
7
7
  ```
8
8
 
9
- Expo Go can't load native modules, so you'll need a dev build. See [Setup](docs/setup.md).
9
+ Needs Expo SDK 58+ and a development build (Expo Go can't load native modules).
10
10
 
11
- ## Pick one mode
11
+ ## Quick start
12
12
 
13
- | You want to… | Use | Needs |
14
- |---|---|---|
15
- | Send to everyone following a topic (`news`, `order-42`) | [**Interests**](docs/interests.md) | Pusher Beams |
16
- | Send to a signed-in user on all their devices | [**Users**](docs/users.md) | Pusher Beams + one auth endpoint |
13
+ Add the config plugin to `app.json`:
17
14
 
18
- Each mode has its own object. Use one, ignore the other.
15
+ ```json
16
+ ["expo-pusher-push-notifications", { "instanceId": "YOUR_BEAMS_INSTANCE_ID" }]
17
+ ```
19
18
 
20
- ### Interests
19
+ Then in your app:
21
20
 
22
21
  ```ts
23
22
  import { Interests } from 'expo-pusher-push-notifications';
@@ -26,17 +25,41 @@ await Interests.start('YOUR_BEAMS_INSTANCE_ID');
26
25
  await Interests.subscribe('news');
27
26
  ```
28
27
 
29
- ### Users
28
+ That device now gets pushes sent to `news`. Full console steps (APNs, Firebase, Beams) are in [Setup](docs/setup.md).
29
+
30
+ ## Subscribe to interests (topics)
31
+
32
+ Interests are topics like `news`, `order-42`, or `team-7`. Every device subscribed to one gets the push.
33
+
34
+ ```ts
35
+ await Interests.subscribe('order-42');
36
+ await Interests.unsubscribe('order-42');
37
+ ```
38
+
39
+ More in [Interests](docs/interests.md).
40
+
41
+ ## Bind a device to a user
42
+
43
+ To get pushes meant for a specific signed-in user on all their devices, bind the device to that user.
30
44
 
31
45
  ```ts
32
46
  import { Users } from 'expo-pusher-push-notifications';
33
47
 
34
48
  await Users.start('YOUR_BEAMS_INSTANCE_ID');
35
- await Users.login('user-123', { url: 'https://api.example.com/beams-auth' });
36
- // sign-out: await Users.logout();
49
+
50
+ // after your own sign-in (url = your Beams token provider)
51
+ await Users.login('user-123', {
52
+ url: 'YOUR_BEAMS_TOKEN_URL',
53
+ headers: { Authorization: `Bearer ${sessionToken}` },
54
+ });
55
+
56
+ // on sign-out
57
+ await Users.logout();
37
58
  ```
38
59
 
39
- ## Works in both modes
60
+ You can use interests and users together. More in [Users](docs/users.md).
61
+
62
+ ## Extras
40
63
 
41
64
  ```ts
42
65
  import { addListener, createChannel, setBadgeCount, scheduleLocalNotification } from 'expo-pusher-push-notifications';
@@ -47,27 +70,22 @@ await setBadgeCount(3);
47
70
  await scheduleLocalNotification({ title: 'Stand up', seconds: 600, sound: 'alarm.wav' });
48
71
  ```
49
72
 
50
- Bundle sounds with the config plugin:
51
-
52
- ```json
53
- ["expo-pusher-push-notifications", { "sounds": ["./assets/alarm.wav"] }]
54
- ```
55
-
56
- More: [sounds, channels, badges, local notifications](docs/extras.md).
73
+ Custom sounds go in the plugin's `sounds` option. Details in [Extras](docs/extras.md).
57
74
 
58
75
  ## Docs
59
76
 
60
- - [Setup](docs/setup.md): install, config plugin options, Firebase / APNs / Beams console steps
61
- - [Interests](docs/interests.md) · [Users](docs/users.md)
77
+ - [Setup](docs/setup.md)
78
+ - [Interests](docs/interests.md)
79
+ - [Users](docs/users.md)
62
80
  - [Sounds, channels, badges, local notifications](docs/extras.md)
63
81
  - [Full API](docs/api.md)
64
82
  - [Migrating from react-native-pusher-push-notifications](docs/migrating.md)
65
83
 
66
- ## Heads up
84
+ ## Good to know
67
85
 
68
- - On iOS this module owns the notification delegate, and on Android it owns the FCM service. Don't run it alongside `expo-notifications` or `@react-native-firebase/messaging`.
69
- - Want a raw FCM / APNs token to send from your own server, without Beams? That's not what this package is for. Use [`expo-notifications`](https://docs.expo.dev/versions/latest/sdk/notifications/) and `getDevicePushTokenAsync()`.
70
- - Need realtime Pusher **Channels** (websockets)? That's a different product. Use [`pusher-js`](https://github.com/pusher/pusher-js); it works in Expo as is.
86
+ - This module owns the iOS notification delegate and the Android FCM service, so don't run it alongside `expo-notifications` or `@react-native-firebase/messaging`.
87
+ - Want a raw FCM / APNs token without Beams? Use [`expo-notifications`](https://docs.expo.dev/versions/latest/sdk/notifications/) instead.
88
+ - Need realtime Pusher **Channels** (websockets)? Use [`pusher-js`](https://github.com/pusher/pusher-js).
71
89
 
72
90
  ## License
73
91
 
@@ -1,5 +1,5 @@
1
1
  /**
2
- * Pusher Beams delivery mode.
2
+ * Which Beams auth path the app uses.
3
3
  *
4
4
  * - `interests`: devices subscribe to named interests; your server calls Beams `publishToInterests`.
5
5
  * - `users`: the device is bound to a user via `setUserId`; your server calls Beams `publishToUsers`.
@@ -8,12 +8,12 @@ export type PusherTransportMode = 'interests' | 'users';
8
8
  export interface PusherConfig {
9
9
  /** Pusher Beams instance ID. */
10
10
  instanceId: string;
11
- /** Defaults to `interests`. */
11
+ /** Beams auth path: `interests` (default) or `users`. */
12
12
  mode?: PusherTransportMode;
13
13
  /** Ask for notification permission (iOS alert/sound/badge, Android 13+ POST_NOTIFICATIONS) during start. Default true. */
14
14
  requestPermission?: boolean;
15
15
  }
16
- /** Remote token endpoint used by the Beams SDK in `users` mode. */
16
+ /** Remote token endpoint used by the Beams SDK when binding a device to a user. */
17
17
  export interface BeamsTokenProvider {
18
18
  /** HTTPS endpoint on your backend that returns `{ token: string }`. */
19
19
  url: string;
@@ -21,7 +21,7 @@ export interface BeamsTokenProvider {
21
21
  queryParams?: Record<string, string>;
22
22
  }
23
23
  /**
24
- * `users` mode auth: either a remote token provider (recommended), or a pre-fetched Beams token string
24
+ * User auth: either a remote token provider (recommended), or a pre-fetched Beams token string
25
25
  * (the b8ne `setUserId(userId, token)` style).
26
26
  */
27
27
  export type BeamsAuth = BeamsTokenProvider | string;
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoPusherPushNotifications.types.d.ts","sourceRoot":"","sources":["../src/ExpoPusherPushNotifications.types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,OAAO,CAAC;AAExD,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,+BAA+B;IAC/B,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,0HAA0H;IAC1H,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,mEAAmE;AACnE,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,kBAAkB,GAAG,MAAM,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,4GAA4G;IAC5G,QAAQ,EAAE,YAAY,GAAG,YAAY,GAAG,QAAQ,CAAC;CAClD;AAED,MAAM,WAAW,eAAe;IAC9B,2GAA2G;IAC3G,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/B,IAAI,EAAE,MAAM,C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AC;IACjE,KAAK,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,uCAAuC,CAAC"}
1
+ {"version":3,"file":"ExpoPusherPushNotifications.types.d.ts","sourceRoot":"","sources":["../src/ExpoPusherPushNotifications.types.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,MAAM,mBAAmB,GAAG,WAAW,GAAG,OAAO,CAAC;AAExD,MAAM,WAAW,YAAY;IAC3B,gCAAgC;IAChC,UAAU,EAAE,MAAM,CAAC;IACnB,yDAAyD;IACzD,IAAI,CAAC,EAAE,mBAAmB,CAAC;IAC3B,0HAA0H;IAC1H,iBAAiB,CAAC,EAAE,OAAO,CAAC;CAC7B;AAED,mFAAmF;AACnF,MAAM,WAAW,kBAAkB;IACjC,uEAAuE;IACvE,GAAG,EAAE,MAAM,CAAC;IACZ,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IACjC,WAAW,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACtC;AAED;;;GAGG;AACH,MAAM,MAAM,SAAS,GAAG,kBAAkB,GAAG,MAAM,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC9B,4GAA4G;IAC5G,QAAQ,EAAE,YAAY,GAAG,YAAY,GAAG,QAAQ,CAAC;CAClD;AAED,MAAM,WAAW,eAAe;IAC9B,2GAA2G;IAC3G,WAAW,EAAE,MAAM,CAAC;IACpB,IAAI,EAAE,KAAK,GAAG,MAAM,CAAC;CACtB;AAED,MAAM,WAAW,yBAAyB;IACxC,SAAS,EAAE,MAAM,EAAE,CAAC;CACrB;AAED,MAAM,WAAW,gBAAgB;IAC/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BAAyB,KAAK,IAAI,CAAC;IACjE,KAAK,EAAE,CAAC,KAAK,EAAE,gBAAgB,KAAK,IAAI,CAAC;CAC1C,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,MAAM,uCAAuC,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ExpoPusherPushNotifications.types.js","sourceRoot":"","sources":["../src/ExpoPusherPushNotifications.types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Pusher Beams delivery mode.\n *\n * - `interests`: devices subscribe to named interests; your server calls Beams `publishToInterests`.\n * - `users`: the device is bound to a user via `setUserId`; your server calls Beams `publishToUsers`.\n */\nexport type PusherTransportMode = 'interests' | 'users';\n\nexport interface PusherConfig {\n /** Pusher Beams instance ID. */\n instanceId: string;\n /** Defaults to `interests`. */\n mode?: PusherTransportMode;\n /** Ask for notification permission (iOS alert/sound/badge, Android 13+ POST_NOTIFICATIONS) during start. Default true. */\n requestPermission?: boolean;\n}\n\n/** Remote token endpoint used by the Beams SDK in `users` mode. */\nexport interface BeamsTokenProvider {\n /** HTTPS endpoint on your backend that returns `{ token: string }`. */\n url: string;\n headers?: Record<string, string>;\n queryParams?: Record<string, string>;\n}\n\n/**\n * `users` mode auth: either a remote token provider (recommended), or a pre-fetched Beams token string\n * (the b8ne `setUserId(userId, token)` style).\n */\nexport type BeamsAuth = BeamsTokenProvider | string;\n\nexport interface PusherNotification {\n title?: string;\n body?: string;\n data: Record<string, unknown>;\n /** `foreground`: received while running; `background`: received in background; `opened`: user tapped it. */\n appState: 'foreground' | 'background' | 'opened';\n}\n\nexport interface RegisteredEvent {\n /** Native token the device registered with (FCM on Android, hex APNs on iOS). Beams handles it for you. */\n deviceToken: string;\n type: 'fcm' | 'apns';\n}\n\nexport interface SubscriptionsChangedEvent {\n interests: string[];\n}\n\nexport interface PusherErrorEvent {\n code: string;\n message: string;\n}\n\nexport type PermissionStatus = 'granted' | 'denied' | 'undetermined' | 'provisional';\n\nexport type AndroidImportance = 'min' | 'low' | 'default' | 'high' | 'max';\n\nexport interface AndroidNotificationChannel {\n id: string;\n name: string;\n description?: string;\n importance?: AndroidImportance;\n /** Bundled sound file name WITHOUT path, e.g. `ding.wav` or `ding`. Must be listed in the plugin's `sounds`. `null` = silent. */\n sound?: string | null;\n vibrate?: boolean;\n lightColor?: string;\n showBadge?: boolean;\n}\n\nexport interface LocalNotification {\n title?: string;\n body?: string;\n data?: Record<string, string>;\n /** Bundled sound file name, e.g. `ding.wav`; `default` for system sound. On Android 8+ the channel's sound wins. */\n sound?: string;\n /** Android channel id. Defaults to the plugin's default channel. */\n channelId?: string;\n /** iOS badge to set with this notification. */\n badge?: number;\n}\n\nexport interface ScheduledNotification extends LocalNotification {\n /** Stable id; reuse to replace. Generated if omitted. */\n id?: string;\n /** Fire after this many seconds (>= 1). */\n seconds: number;\n}\n\nexport type ExpoPusherPushNotificationsModuleEvents = {\n notification: (event: PusherNotification) => void;\n registered: (event: RegisteredEvent) => void;\n subscriptionsChanged: (event: SubscriptionsChangedEvent) => void;\n error: (event: PusherErrorEvent) => void;\n};\n\nexport type PusherEventName = keyof ExpoPusherPushNotificationsModuleEvents;\n"]}
1
+ {"version":3,"file":"ExpoPusherPushNotifications.types.js","sourceRoot":"","sources":["../src/ExpoPusherPushNotifications.types.ts"],"names":[],"mappings":"","sourcesContent":["/**\n * Which Beams auth path the app uses.\n *\n * - `interests`: devices subscribe to named interests; your server calls Beams `publishToInterests`.\n * - `users`: the device is bound to a user via `setUserId`; your server calls Beams `publishToUsers`.\n */\nexport type PusherTransportMode = 'interests' | 'users';\n\nexport interface PusherConfig {\n /** Pusher Beams instance ID. */\n instanceId: string;\n /** Beams auth path: `interests` (default) or `users`. */\n mode?: PusherTransportMode;\n /** Ask for notification permission (iOS alert/sound/badge, Android 13+ POST_NOTIFICATIONS) during start. Default true. */\n requestPermission?: boolean;\n}\n\n/** Remote token endpoint used by the Beams SDK when binding a device to a user. */\nexport interface BeamsTokenProvider {\n /** HTTPS endpoint on your backend that returns `{ token: string }`. */\n url: string;\n headers?: Record<string, string>;\n queryParams?: Record<string, string>;\n}\n\n/**\n * User auth: either a remote token provider (recommended), or a pre-fetched Beams token string\n * (the b8ne `setUserId(userId, token)` style).\n */\nexport type BeamsAuth = BeamsTokenProvider | string;\n\nexport interface PusherNotification {\n title?: string;\n body?: string;\n data: Record<string, unknown>;\n /** `foreground`: received while running; `background`: received in background; `opened`: user tapped it. */\n appState: 'foreground' | 'background' | 'opened';\n}\n\nexport interface RegisteredEvent {\n /** Native token the device registered with (FCM on Android, hex APNs on iOS). Beams handles it for you. */\n deviceToken: string;\n type: 'fcm' | 'apns';\n}\n\nexport interface SubscriptionsChangedEvent {\n interests: string[];\n}\n\nexport interface PusherErrorEvent {\n code: string;\n message: string;\n}\n\nexport type PermissionStatus = 'granted' | 'denied' | 'undetermined' | 'provisional';\n\nexport type AndroidImportance = 'min' | 'low' | 'default' | 'high' | 'max';\n\nexport interface AndroidNotificationChannel {\n id: string;\n name: string;\n description?: string;\n importance?: AndroidImportance;\n /** Bundled sound file name WITHOUT path, e.g. `ding.wav` or `ding`. Must be listed in the plugin's `sounds`. `null` = silent. */\n sound?: string | null;\n vibrate?: boolean;\n lightColor?: string;\n showBadge?: boolean;\n}\n\nexport interface LocalNotification {\n title?: string;\n body?: string;\n data?: Record<string, string>;\n /** Bundled sound file name, e.g. `ding.wav`; `default` for system sound. On Android 8+ the channel's sound wins. */\n sound?: string;\n /** Android channel id. Defaults to the plugin's default channel. */\n channelId?: string;\n /** iOS badge to set with this notification. */\n badge?: number;\n}\n\nexport interface ScheduledNotification extends LocalNotification {\n /** Stable id; reuse to replace. Generated if omitted. */\n id?: string;\n /** Fire after this many seconds (>= 1). */\n seconds: number;\n}\n\nexport type ExpoPusherPushNotificationsModuleEvents = {\n notification: (event: PusherNotification) => void;\n registered: (event: RegisteredEvent) => void;\n subscriptionsChanged: (event: SubscriptionsChangedEvent) => void;\n error: (event: PusherErrorEvent) => void;\n};\n\nexport type PusherEventName = keyof ExpoPusherPushNotificationsModuleEvents;\n"]}
package/build/index.d.ts CHANGED
@@ -1,7 +1,7 @@
1
1
  import type { EventSubscription } from 'expo-modules-core';
2
2
  import type { AndroidNotificationChannel, BeamsAuth, ExpoPusherPushNotificationsModuleEvents, LocalNotification, PermissionStatus, PusherConfig, PusherEventName, PusherNotification, PusherTransportMode, ScheduledNotification } from './ExpoPusherPushNotifications.types';
3
3
  export * from './ExpoPusherPushNotifications.types';
4
- /** Starts Pusher Beams in `interests` (default) or `users` mode. */
4
+ /** Starts Pusher Beams. */
5
5
  export declare function start(config: PusherConfig): Promise<void>;
6
6
  export declare function getMode(): PusherTransportMode;
7
7
  export declare function subscribe(interest: string): Promise<void>;
@@ -28,17 +28,17 @@ export declare function dismissAllNotifications(): Promise<void>;
28
28
  export declare function getInitialNotification(): Promise<PusherNotification | null>;
29
29
  export declare function clearAllState(): Promise<void>;
30
30
  export declare function stop(): Promise<void>;
31
- /** Adds an event listener. Events fire in all modes. */
31
+ /** Adds an event listener. Events fire for interests and users alike. */
32
32
  export declare function addListener<E extends PusherEventName>(eventName: E, listener: ExpoPusherPushNotificationsModuleEvents[E]): EventSubscription;
33
33
  /** Alias for `addListener` (old package's `on()`). */
34
34
  export declare const on: typeof addListener;
35
35
  /**
36
- * Mode 1 — Pusher Beams **interests** (topic broadcast).
36
+ * Pusher Beams **interests** (topic broadcast).
37
37
  * Use when many devices should get the same push: "news", "order-42", "team-7".
38
38
  * Server: `beams.publishToInterests([...], payload)`.
39
39
  */
40
40
  export declare const Interests: {
41
- /** Start Beams in interests mode. */
41
+ /** Start Beams. */
42
42
  readonly start: (instanceId: string, opts?: {
43
43
  requestPermission?: boolean;
44
44
  }) => Promise<void>;
@@ -52,12 +52,12 @@ export declare const Interests: {
52
52
  readonly stop: typeof stop;
53
53
  };
54
54
  /**
55
- * Mode 2 — Pusher Beams **authenticated users** (push to a person, across all their devices).
55
+ * Pusher Beams **authenticated users** (push to a person, across all their devices).
56
56
  * Use when your backend thinks in user ids: "send to user-123".
57
57
  * Server: `beams.publishToUsers(['user-123'], payload)` + a token endpoint (`beams.generateToken`).
58
58
  */
59
59
  export declare const Users: {
60
- /** Start Beams in users mode. Call `login()` after your own sign-in. */
60
+ /** Start Beams. Call `login()` after your own sign-in. */
61
61
  readonly start: (instanceId: string, opts?: {
62
62
  requestPermission?: boolean;
63
63
  }) => Promise<void>;
@@ -69,7 +69,7 @@ export declare const Users: {
69
69
  };
70
70
  declare const _default: {
71
71
  readonly Interests: {
72
- /** Start Beams in interests mode. */
72
+ /** Start Beams. */
73
73
  readonly start: (instanceId: string, opts?: {
74
74
  requestPermission?: boolean;
75
75
  }) => Promise<void>;
@@ -83,7 +83,7 @@ declare const _default: {
83
83
  readonly stop: typeof stop;
84
84
  };
85
85
  readonly Users: {
86
- /** Start Beams in users mode. Call `login()` after your own sign-in. */
86
+ /** Start Beams. Call `login()` after your own sign-in. */
87
87
  readonly start: (instanceId: string, opts?: {
88
88
  requestPermission?: boolean;
89
89
  }) => Promise<void>;
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAG3D,OAAO,KAAK,EACV,0BAA0B,EAC1B,SAAS,EACT,uCAAuC,EACvC,iBAAiB,EACjB,gBAAgB,EAChB,YAAY,EACZ,eAAe,EACf,kBAAkB,EAClB,mBAAmB,EACnB,qBAAqB,EACtB,MAAM,qCAAqC,CAAC;AAE7C,cAAc,qCAAqC,CAAC;AAWpD,oEAAoE;AACpE,wBAAsB,KAAK,CAAC,MAAM,EAAE,YAAY,GAAG,OAAO,CAAC,IAAI,CAAC,CAM/D;AAED,wBAAgB,OAAO,IAAI,mBAAmB,CAE7C;AAGD,wBAAsB,SAAS,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAG/D;AACD,wBAAsB,WAAW,CAAC,QAAQ,EAAE,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4CAA4C;;;CAGpC,CAAC;;;QA3BT,mBAAmB;qCACC,MAAM,SAAQ;YAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;SAAE;;;;;;QAOjE,0CAA0C;;;;;QAW1C,0DAA0D;qCACtC,MAAM,SAAQ;YAAE,iBAAiB,CAAC,EAAE,OAAO,CAAA;SAAE;QAEjE,yGAAyG;;QAEzG,4CAA4C;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAK9C,wBAWW"}
package/build/index.js CHANGED
@@ -7,7 +7,7 @@ function assertBeams(fn) {
7
7
  if (!started)
8
8
  throw new Error(`${PREFIX}: call start() before ${fn}().`);
9
9
  }
10
- /** Starts Pusher Beams in `interests` (default) or `users` mode. */
10
+ /** Starts Pusher Beams. */
11
11
  export async function start(config) {
12
12
  if (!config.instanceId)
13
13
  throw new Error(`${PREFIX}: instanceId is required.`);
@@ -20,7 +20,7 @@ export async function start(config) {
20
20
  export function getMode() {
21
21
  return currentMode;
22
22
  }
23
- // ---- Mode 1: Beams interests ----
23
+ // ---- Interests (topics) ----
24
24
  export async function subscribe(interest) {
25
25
  assertBeams('subscribe');
26
26
  await Native.addDeviceInterest(interest);
@@ -41,7 +41,7 @@ export async function clearSubscriptions() {
41
41
  assertBeams('clearSubscriptions');
42
42
  await Native.clearDeviceInterests();
43
43
  }
44
- // ---- Mode 2: Beams authenticated users ----
44
+ // ---- Bind a device to a user ----
45
45
  /** Pass a token provider `{ url, headers?, queryParams? }` or a pre-fetched Beams token string. */
46
46
  export async function setUserId(userId, auth) {
47
47
  assertBeams('setUserId');
@@ -109,24 +109,23 @@ export async function stop() {
109
109
  await Native.stop();
110
110
  started = false;
111
111
  }
112
- /** Adds an event listener. Events fire in all modes. */
112
+ /** Adds an event listener. Events fire for interests and users alike. */
113
113
  export function addListener(eventName, listener) {
114
114
  return Native.addListener(eventName, listener);
115
115
  }
116
116
  /** Alias for `addListener` (old package's `on()`). */
117
117
  export const on = addListener;
118
118
  // ---------------------------------------------------------------------------
119
- // Mode-scoped API. Pick ONE of these two and ignore the other.
120
- // Everything below (sounds, channels, badges, local notifications, events)
121
- // is shared and works in every mode.
119
+ // Convenience objects. Use either or both; everything else (sounds,
120
+ // channels, badges, local notifications, events) works the same either way.
122
121
  // ---------------------------------------------------------------------------
123
122
  /**
124
- * Mode 1 — Pusher Beams **interests** (topic broadcast).
123
+ * Pusher Beams **interests** (topic broadcast).
125
124
  * Use when many devices should get the same push: "news", "order-42", "team-7".
126
125
  * Server: `beams.publishToInterests([...], payload)`.
127
126
  */
128
127
  export const Interests = {
129
- /** Start Beams in interests mode. */
128
+ /** Start Beams. */
130
129
  start: (instanceId, opts = {}) => start({ ...opts, instanceId, mode: 'interests' }),
131
130
  subscribe,
132
131
  unsubscribe,
@@ -138,12 +137,12 @@ export const Interests = {
138
137
  stop,
139
138
  };
140
139
  /**
141
- * Mode 2 — Pusher Beams **authenticated users** (push to a person, across all their devices).
140
+ * Pusher Beams **authenticated users** (push to a person, across all their devices).
142
141
  * Use when your backend thinks in user ids: "send to user-123".
143
142
  * Server: `beams.publishToUsers(['user-123'], payload)` + a token endpoint (`beams.generateToken`).
144
143
  */
145
144
  export const Users = {
146
- /** Start Beams in users mode. Call `login()` after your own sign-in. */
145
+ /** Start Beams. Call `login()` after your own sign-in. */
147
146
  start: (instanceId, opts = {}) => start({ ...opts, instanceId, mode: 'users' }),
148
147
  /** Bind this device to `userId`. `auth` is your token endpoint, or a Beams token you already fetched. */
149
148
  login: setUserId,
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,qCAAqC,CAAC;AAczD,cAAc,qCAAqC,CAAC;AAEpD,IAAI,WAAW,GAAwB,WAAW,CAAC;AACnD,IAAI,OAAO,GAAG,KAAK,CAAC;AAEpB,MAAM,MAAM,GAAG,gCAAgC,CAAC;AAEhD,SAAS,WAAW,CAAC,EAAU;IAC7B,IAAI,CAAC,OAAO;QAA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AE;CAC5B,CAAC","sourcesContent":["import type { EventSubscription } from 'expo-modules-core';\n\nimport Native from './ExpoPusherPushNotificationsModule';\nimport type {\n AndroidNotificationChannel,\n BeamsAuth,\n ExpoPusherPushNotificationsModuleEvents,\n LocalNotification,\n PermissionStatus,\n PusherConfig,\n PusherEventName,\n PusherNotification,\n PusherTransportMode,\n ScheduledNotification,\n} from './ExpoPusherPushNotifications.types';\n\nexport * from './ExpoPusherPushNotifications.types';\n\nlet currentMode: PusherTransportMode = 'interests';\nlet started = false;\n\nconst PREFIX = 'expo-pusher-push-notifications';\n\nfunction assertBeams(fn: string): void {\n if (!started) throw new Error(`${PREFIX}: call start() before ${fn}().`);\n}\n\n/** Starts Pusher Beams in `interests` (default) or `users` mode. */\nexport async function start(config: PusherConfig): Promise<void> {\n if (!config.instanceId) throw new Error(`${PREFIX}: instanceId is required.`);\n if (config.requestPermission !== false) await Native.requestPermission();\n currentMode = config.mode ?? 'interests';\n await Native.start(config.instanceId);\n started = true;\n}\n\nexport function getMode(): PusherTransportMode {\n return currentMode;\n}\n\n// ---- Mode 1: Beams interests ----\nexport async function subscribe(interest: string): Promise<void> {\n assertBeams('subscribe');\n await Native.addDeviceInterest(interest);\n}\nexport async function unsubscribe(interest: string): Promise<void> {\n assertBeams('unsubscribe');\n await Native.removeDeviceInterest(interest);\n}\nexport async function setSubscriptions(interests: string[]): Promise<void> {\n assertBeams('setSubscriptions');\n await Native.setDeviceInterests(interests);\n}\nexport async function getSubscriptions(): Promise<string[]> {\n assertBeams('getSubscriptions');\n return Native.getDeviceInterests();\n}\nexport async function clearSubscriptions(): Promise<void> {\n assertBeams('clearSubscriptions');\n await Native.clearDeviceInterests();\n}\n\n// ---- Mode 2: Beams authenticated users ----\n/** Pass a token provider `{ url, headers?, queryParams? }` or a pre-fetched Beams token string. */\nexport async function setUserId(userId: string, auth: BeamsAuth): Promise<void> {\n assertBeams('setUserId');\n if (typeof auth === 'string') await Native.setUserIdWithToken(userId, auth);\n else await Native.setUserId(userId, auth);\n}\n\n// ---- Permissions ----\nexport function requestPermission(): Promise<PermissionStatus> {\n return Native.requestPermission();\n}\nexport function getPermissionStatus(): Promise<PermissionStatus> {\n return Native.getPermissionStatus();\n}\n\n// ---- Android notification channels (no-ops on iOS) ----\nexport function createChannel(channel: AndroidNotificationChannel): Promise<void> {\n return Native.createChannel(channel);\n}\nexport function deleteChannel(id: string): Promise<void> {\n return Native.deleteChannel(id);\n}\nexport function getChannels(): Promise<AndroidNotificationChannel[]> {\n return Native.getChannels();\n}\n\n// ---- Badge ----\nexport function getBadgeCount(): Promise<number> {\n return Native.getBadgeCount();\n}\nexport function setBadgeCount(count: number): Promise<void> {\n return Native.setBadgeCount(Math.max(0, Math.floor(count)));\n}\nexport async function incrementBadgeCount(by = 1): Promise<number> {\n const next = (await Native.getBadgeCount()) + by;\n await setBadgeCount(next);\n return Math.max(0, next);\n}\n\n// ---- Local notifications ----\nexport function presentLocalNotification(n: LocalNotification): Promise<string> {\n return Native.presentLocalNotification(n);\n}\nexport function scheduleLocalNotification(n: ScheduledNotification): Promise<string> {\n if (!(n.seconds >= 1)) throw new Error(`${PREFIX}: seconds must be >= 1.`);\n return Native.scheduleLocalNotification(n);\n}\nexport function cancelScheduledNotification(id: string): Promise<void> {\n return Native.cancelScheduledNotification(id);\n}\nexport function cancelAllScheduledNotifications(): Promise<void> {\n return Native.cancelAllScheduledNotifications();\n}\nexport function dismissAllNotifications(): Promise<void> {\n return Native.dismissAllNotifications();\n}\n/** The notification whose tap launched the app (cold start), if any. */\nexport function getInitialNotification(): Promise<PusherNotification | null> {\n return Native.getInitialNotification();\n}\n\n// ---- Common ----\nexport async function clearAllState(): Promise<void> {\n await Native.clearAllState();\n}\nexport async function stop(): Promise<void> {\n await Native.stop();\n started = false;\n}\n\n/** Adds an event listener. Events fire in all modes. */\nexport function addListener<E extends PusherEventName>(\n eventName: E,\n listener: ExpoPusherPushNotificationsModuleEvents[E]\n): EventSubscription {\n return Native.addListener(eventName, listener);\n}\n/** Alias for `addListener` (old package's `on()`). */\nexport const on = addListener;\n\n// ---------------------------------------------------------------------------\n// Mode-scoped API. Pick ONE of these two and ignore the other.\n// Everything below (sounds, channels, badges, local notifications, events)\n// is shared and works in every mode.\n// ---------------------------------------------------------------------------\n\n/**\n * Mode 1 — Pusher Beams **interests** (topic broadcast).\n * Use when many devices should get the same push: \"news\", \"order-42\", \"team-7\".\n * Server: `beams.publishToInterests([...], payload)`.\n */\nexport const Interests = {\n /** Start Beams in interests mode. */\n start: (instanceId: string, opts: { requestPermission?: boolean } = {}) =>\n start({ ...opts, instanceId, mode: 'interests' }),\n subscribe,\n unsubscribe,\n set: setSubscriptions,\n get: getSubscriptions,\n clear: clearSubscriptions,\n /** Forget everything (call on logout). */\n reset: clearAllState,\n stop,\n} as const;\n\n/**\n * Mode 2 — Pusher Beams **authenticated users** (push to a person, across all their devices).\n * Use when your backend thinks in user ids: \"send to user-123\".\n * Server: `beams.publishToUsers(['user-123'], payload)` + a token endpoint (`beams.generateToken`).\n */\nexport const Users = {\n /** Start Beams in users mode. Call `login()` after your own sign-in. */\n start: (instanceId: string, opts: { requestPermission?: boolean } = {}) =>\n start({ ...opts, instanceId, mode: 'users' }),\n /** Bind this device to `userId`. `auth` is your token endpoint, or a Beams token you already fetched. */\n login: setUserId,\n /** Unbind the device (call on sign-out). */\n logout: clearAllState,\n stop,\n} as const;\n\nexport default {\n Interests, Users,\n start, getMode,\n subscribe, unsubscribe, setSubscriptions, getSubscriptions, clearSubscriptions,\n setUserId,\n requestPermission, getPermissionStatus,\n createChannel, deleteChannel, getChannels,\n getBadgeCount, setBadgeCount, incrementBadgeCount,\n presentLocalNotification, scheduleLocalNotification, cancelScheduledNotification,\n cancelAllScheduledNotifications, dismissAllNotifications, getInitialNotification,\n clearAllState, stop, addListener, on,\n} as const;\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAEA,OAAO,MAAM,MAAM,qCAAqC,CAAC;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aAAa,EAAE,WAAW;IACzC,aAAa,EAAE,aAAa,EAAE,mBAAmB;IACjD,wBAAwB,EAAE,yBAAyB,EAAE,2BAA2B;IAChF,+BAA+B,EAAE,uBAAuB,EAAE,sBAAsB;IAChF,aAAa,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE;CAC5B,CAAC","sourcesContent":["import type { EventSubscription } from 'expo-modules-core';\n\nimport Native from './ExpoPusherPushNotificationsModule';\nimport type {\n AndroidNotificationChannel,\n BeamsAuth,\n ExpoPusherPushNotificationsModuleEvents,\n LocalNotification,\n PermissionStatus,\n PusherConfig,\n PusherEventName,\n PusherNotification,\n PusherTransportMode,\n ScheduledNotification,\n} from './ExpoPusherPushNotifications.types';\n\nexport * from './ExpoPusherPushNotifications.types';\n\nlet currentMode: PusherTransportMode = 'interests';\nlet started = false;\n\nconst PREFIX = 'expo-pusher-push-notifications';\n\nfunction assertBeams(fn: string): void {\n if (!started) throw new Error(`${PREFIX}: call start() before ${fn}().`);\n}\n\n/** Starts Pusher Beams. */\nexport async function start(config: PusherConfig): Promise<void> {\n if (!config.instanceId) throw new Error(`${PREFIX}: instanceId is required.`);\n if (config.requestPermission !== false) await Native.requestPermission();\n currentMode = config.mode ?? 'interests';\n await Native.start(config.instanceId);\n started = true;\n}\n\nexport function getMode(): PusherTransportMode {\n return currentMode;\n}\n\n// ---- Interests (topics) ----\nexport async function subscribe(interest: string): Promise<void> {\n assertBeams('subscribe');\n await Native.addDeviceInterest(interest);\n}\nexport async function unsubscribe(interest: string): Promise<void> {\n assertBeams('unsubscribe');\n await Native.removeDeviceInterest(interest);\n}\nexport async function setSubscriptions(interests: string[]): Promise<void> {\n assertBeams('setSubscriptions');\n await Native.setDeviceInterests(interests);\n}\nexport async function getSubscriptions(): Promise<string[]> {\n assertBeams('getSubscriptions');\n return Native.getDeviceInterests();\n}\nexport async function clearSubscriptions(): Promise<void> {\n assertBeams('clearSubscriptions');\n await Native.clearDeviceInterests();\n}\n\n// ---- Bind a device to a user ----\n/** Pass a token provider `{ url, headers?, queryParams? }` or a pre-fetched Beams token string. */\nexport async function setUserId(userId: string, auth: BeamsAuth): Promise<void> {\n assertBeams('setUserId');\n if (typeof auth === 'string') await Native.setUserIdWithToken(userId, auth);\n else await Native.setUserId(userId, auth);\n}\n\n// ---- Permissions ----\nexport function requestPermission(): Promise<PermissionStatus> {\n return Native.requestPermission();\n}\nexport function getPermissionStatus(): Promise<PermissionStatus> {\n return Native.getPermissionStatus();\n}\n\n// ---- Android notification channels (no-ops on iOS) ----\nexport function createChannel(channel: AndroidNotificationChannel): Promise<void> {\n return Native.createChannel(channel);\n}\nexport function deleteChannel(id: string): Promise<void> {\n return Native.deleteChannel(id);\n}\nexport function getChannels(): Promise<AndroidNotificationChannel[]> {\n return Native.getChannels();\n}\n\n// ---- Badge ----\nexport function getBadgeCount(): Promise<number> {\n return Native.getBadgeCount();\n}\nexport function setBadgeCount(count: number): Promise<void> {\n return Native.setBadgeCount(Math.max(0, Math.floor(count)));\n}\nexport async function incrementBadgeCount(by = 1): Promise<number> {\n const next = (await Native.getBadgeCount()) + by;\n await setBadgeCount(next);\n return Math.max(0, next);\n}\n\n// ---- Local notifications ----\nexport function presentLocalNotification(n: LocalNotification): Promise<string> {\n return Native.presentLocalNotification(n);\n}\nexport function scheduleLocalNotification(n: ScheduledNotification): Promise<string> {\n if (!(n.seconds >= 1)) throw new Error(`${PREFIX}: seconds must be >= 1.`);\n return Native.scheduleLocalNotification(n);\n}\nexport function cancelScheduledNotification(id: string): Promise<void> {\n return Native.cancelScheduledNotification(id);\n}\nexport function cancelAllScheduledNotifications(): Promise<void> {\n return Native.cancelAllScheduledNotifications();\n}\nexport function dismissAllNotifications(): Promise<void> {\n return Native.dismissAllNotifications();\n}\n/** The notification whose tap launched the app (cold start), if any. */\nexport function getInitialNotification(): Promise<PusherNotification | null> {\n return Native.getInitialNotification();\n}\n\n// ---- Common ----\nexport async function clearAllState(): Promise<void> {\n await Native.clearAllState();\n}\nexport async function stop(): Promise<void> {\n await Native.stop();\n started = false;\n}\n\n/** Adds an event listener. Events fire for interests and users alike. */\nexport function addListener<E extends PusherEventName>(\n eventName: E,\n listener: ExpoPusherPushNotificationsModuleEvents[E]\n): EventSubscription {\n return Native.addListener(eventName, listener);\n}\n/** Alias for `addListener` (old package's `on()`). */\nexport const on = addListener;\n\n// ---------------------------------------------------------------------------\n// Convenience objects. Use either or both; everything else (sounds,\n// channels, badges, local notifications, events) works the same either way.\n// ---------------------------------------------------------------------------\n\n/**\n * Pusher Beams **interests** (topic broadcast).\n * Use when many devices should get the same push: \"news\", \"order-42\", \"team-7\".\n * Server: `beams.publishToInterests([...], payload)`.\n */\nexport const Interests = {\n /** Start Beams. */\n start: (instanceId: string, opts: { requestPermission?: boolean } = {}) =>\n start({ ...opts, instanceId, mode: 'interests' }),\n subscribe,\n unsubscribe,\n set: setSubscriptions,\n get: getSubscriptions,\n clear: clearSubscriptions,\n /** Forget everything (call on logout). */\n reset: clearAllState,\n stop,\n} as const;\n\n/**\n * Pusher Beams **authenticated users** (push to a person, across all their devices).\n * Use when your backend thinks in user ids: \"send to user-123\".\n * Server: `beams.publishToUsers(['user-123'], payload)` + a token endpoint (`beams.generateToken`).\n */\nexport const Users = {\n /** Start Beams. Call `login()` after your own sign-in. */\n start: (instanceId: string, opts: { requestPermission?: boolean } = {}) =>\n start({ ...opts, instanceId, mode: 'users' }),\n /** Bind this device to `userId`. `auth` is your token endpoint, or a Beams token you already fetched. */\n login: setUserId,\n /** Unbind the device (call on sign-out). */\n logout: clearAllState,\n stop,\n} as const;\n\nexport default {\n Interests, Users,\n start, getMode,\n subscribe, unsubscribe, setSubscriptions, getSubscriptions, clearSubscriptions,\n setUserId,\n requestPermission, getPermissionStatus,\n createChannel, deleteChannel, getChannels,\n getBadgeCount, setBadgeCount, incrementBadgeCount,\n presentLocalNotification, scheduleLocalNotification, cancelScheduledNotification,\n cancelAllScheduledNotifications, dismissAllNotifications, getInitialNotification,\n clearAllState, stop, addListener, on,\n} as const;\n"]}
package/docs/api.md CHANGED
@@ -1,20 +1,20 @@
1
1
  # Full API
2
2
 
3
- The mode objects (`Interests`, `Users`) are thin wrappers over these flat functions. Use whichever you like. The flat ones are kept for people coming from the old packages.
3
+ `Interests` and `Users` are thin wrappers over these flat functions. Use whichever you like. The flat ones are kept for people coming from the old packages.
4
4
 
5
- | Function | Modes | Notes |
5
+ | Function | Used for | Notes |
6
6
  |---|---|---|
7
- | `start({ instanceId, mode?, requestPermission? })` | all | `mode` is `interests` (default) or `users`. |
8
- | `getMode()` | all | |
9
- | `subscribe` / `unsubscribe` / `setSubscriptions` / `getSubscriptions` / `clearSubscriptions` | interests (and users) | Work on both platforms. |
10
- | `setUserId(userId, { url, headers?, queryParams? } \| token)` | users | |
11
- | `requestPermission()` / `getPermissionStatus()` | all | |
12
- | `createChannel` / `deleteChannel` / `getChannels` | all, Android only | |
13
- | `getBadgeCount` / `setBadgeCount` / `incrementBadgeCount` | all | |
14
- | `presentLocalNotification` / `scheduleLocalNotification` / `cancelScheduledNotification` / `cancelAllScheduledNotifications` / `dismissAllNotifications` | all | |
15
- | `getInitialNotification()` | all | |
16
- | `clearAllState()` / `stop()` | all | |
17
- | `addListener(event, cb)` / `on(event, cb)` | all | Return an `EventSubscription`. |
7
+ | `start({ instanceId, mode?, requestPermission? })` | everything | `mode` (optional) is the Beams auth path: `interests` (default) or `users`. |
8
+ | `getMode()` | everything | |
9
+ | `subscribe` / `unsubscribe` / `setSubscriptions` / `getSubscriptions` / `clearSubscriptions` | interests | Work on both platforms. |
10
+ | `setUserId(userId, { url, headers?, queryParams? } \| token)` | binding a user | |
11
+ | `requestPermission()` / `getPermissionStatus()` | everything | |
12
+ | `createChannel` / `deleteChannel` / `getChannels` | Android only | |
13
+ | `getBadgeCount` / `setBadgeCount` / `incrementBadgeCount` | everything | |
14
+ | `presentLocalNotification` / `scheduleLocalNotification` / `cancelScheduledNotification` / `cancelAllScheduledNotifications` / `dismissAllNotifications` | everything | |
15
+ | `getInitialNotification()` | everything | |
16
+ | `clearAllState()` / `stop()` | everything | |
17
+ | `addListener(event, cb)` / `on(event, cb)` | everything | Return an `EventSubscription`. |
18
18
 
19
19
 
20
20
  ---
package/docs/extras.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Sounds, channels, badges, local notifications
2
2
 
3
- All of this works the same in both modes.
3
+ All of this works whether you use interests, users, or both.
4
4
 
5
5
  ## Custom sounds
6
6
 
@@ -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
- # Mode 1: Beams interests
1
+ # Interests (topics)
2
2
 
3
- **Use this 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`.
3
+ Use interests when many devices should get the same push. Think topics: `news`, `order-42`, `team-7`.
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 the `DeviceToken` mode (`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
@@ -1,7 +1,5 @@
1
1
  # Setup
2
2
 
3
- You need this for both modes.
4
-
5
3
  ## Install
6
4
 
7
5
  ```sh
@@ -17,7 +15,6 @@ npx expo install expo-pusher-push-notifications
17
15
  "android": { "package": "com.you.app", "googleServicesFile": "./google-services.json" },
18
16
  "plugins": [
19
17
  ["expo-pusher-push-notifications", {
20
- "mode": "interests",
21
18
  "instanceId": "YOUR_BEAMS_INSTANCE_ID",
22
19
  "apsEnvironment": "development",
23
20
  "sounds": ["./assets/sounds/ding.wav", "./assets/sounds/alarm.caf"],
@@ -40,7 +37,7 @@ Then run `npx expo prebuild` and build a development build. Expo Go cannot load
40
37
 
41
38
  | Option | Default | What it does |
42
39
  |---|---|---|
43
- | `mode` | `interests` | Written to Info.plist and the manifest so native code can read it. |
40
+ | `mode` | `interests` | Which Beams auth path your app uses: `interests`, or `users` if you bind devices to signed-in users. Written to Info.plist and the manifest. You can leave it out. |
44
41
  | `instanceId` | none | Beams instance ID. |
45
42
  | `apsEnvironment` | `development` | Sets the `aps-environment` entitlement. Use `production` for TestFlight and App Store builds. |
46
43
  | `sounds` | `[]` | Sound files to bundle. **Android:** copied to `res/raw` with names lower-cased to `[a-z0-9_]`. **iOS:** copied into the app target and added to its resources. iOS needs `.wav`, `.caf`, or `.aiff` under 30 s. |
@@ -48,14 +45,13 @@ Then run `npx expo prebuild` and build a development build. Expo Go cannot load
48
45
  | `androidDefaultChannelId` | first channel, or `default` | Used by FCM/Beams notifications that don't name a channel. Also sets `com.google.firebase.messaging.default_notification_channel_id`. |
49
46
  | `iosShowInForeground` | `true` | Shows the banner, plays the sound, and updates the badge while the app is in the foreground. |
50
47
 
51
- The plugin also adds the `remote-notification` background mode on iOS. On Android, the library manifest declares one FCM service for all modes (it extends the Beams `MessagingService`), the `POST_NOTIFICATIONS` permission, and a receiver for scheduled local notifications.
48
+ The plugin also adds the `remote-notification` background mode on iOS. On Android, the library manifest declares one FCM service (it extends the Beams `MessagingService`), the `POST_NOTIFICATIONS` permission, and a receiver for scheduled local notifications.
52
49
 
53
50
  ## Console setup
54
51
 
55
52
  1. **iOS:** enable the Push Notifications capability. The plugin sets the entitlement. Create an APNs auth key (.p8).
56
53
  2. **Android:** create a Firebase project, download `google-services.json`, and point `android.googleServicesFile` at it.
57
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.
58
- 4. **Users mode only:** 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/)).
59
55
 
60
56
  ## Permissions
61
57
 
package/docs/users.md CHANGED
@@ -1,18 +1,17 @@
1
- # Mode 2: Beams authenticated users
1
+ # Bind a device to a user
2
2
 
3
- **Use this when** your backend thinks in user ids: "send this to user-123", on every device they're signed in on.
4
- You need a Pusher Beams instance and one auth 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.
5
4
 
6
- ## Client
5
+ ## In the app
7
6
 
8
7
  ```ts
9
8
  import { Users } from 'expo-pusher-push-notifications';
10
9
 
11
10
  await Users.start('YOUR_BEAMS_INSTANCE_ID');
12
11
 
13
- // 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).
14
13
  await Users.login('user-123', {
15
- url: 'https://api.example.com/pusher/beams-auth',
14
+ url: 'YOUR_BEAMS_TOKEN_URL',
16
15
  headers: { Authorization: `Bearer ${sessionToken}` },
17
16
  });
18
17
 
@@ -23,23 +22,6 @@ await Users.login('user-123', beamsToken);
23
22
  await Users.logout();
24
23
  ```
25
24
 
26
- ## Server (Node)
27
-
28
- ```js
29
- // GET /pusher/beams-auth (must be authenticated, and user_id must match the session)
30
- app.get('/pusher/beams-auth', requireSession, (req, res) => {
31
- res.json(beams.generateToken(req.user.id)); // { token: '…' }
32
- });
33
-
34
- // Send
35
- await beams.publishToUsers(['user-123'], {
36
- apns: { aps: { alert: { title: 'Hey', body: 'You have a new message' }, sound: 'ding.wav' } },
37
- fcm: { notification: { title: 'Hey', body: 'You have a new message', android_channel_id: 'messages' } },
38
- });
39
- ```
40
-
41
- See Pusher's [auth guide](https://pusher.com/docs/beams/guides/publish-to-specific-user/).
42
-
43
25
  ## API
44
26
 
45
27
  | Call | What it does |
@@ -49,7 +31,7 @@ See Pusher's [auth guide](https://pusher.com/docs/beams/guides/publish-to-specif
49
31
  | `Users.logout()` | Unbinds the device from the user. |
50
32
  | `Users.stop()` | Stop Beams. |
51
33
 
52
- Interests still work in this mode if you want both.
34
+ You can still subscribe to interests on a device that's bound to a user.
53
35
 
54
36
 
55
37
  ---
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "expo-pusher-push-notifications",
3
- "version": "0.4.0",
4
- "description": "Pusher Beams push notifications for Expo (interests or authenticated users), with custom sounds, Android channels, badges and local notifications",
3
+ "version": "0.4.2",
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",
7
7
  "scripts": {
@@ -14,7 +14,7 @@ export interface PusherPluginProps {
14
14
  instanceId?: string;
15
15
  /** APNs environment for the aps-environment entitlement. Defaults to "development". */
16
16
  apsEnvironment?: 'development' | 'production';
17
- /** Default mode written to native config. Defaults to "interests". */
17
+ /** Beams auth path written to native config (`interests` or `users`). Defaults to "interests". */
18
18
  mode?: 'interests' | 'users';
19
19
  /**
20
20
  * Sound files (paths relative to the project root) to bundle. Android: copied to res/raw