DID THIS ARTICLE SOLVE YOUR ISSUE?
Let us know so we can improve!
Let us know so we can improve!
This section provides API reference details for the Push Messaging module in the React Native unified plugin.
Enables push messaging in the native Marketing Cloud SDK.
1PushMessagingSdkModule.enablePush();void1import { PushModule } from "@sfmc/react-native-push";
2import type { PushApi } from "@sfmc/react-native-push";
3
4const push: PushApi = await PushModule.requestSdk();
5push.enablePush();Disables push messaging in the native Marketing Cloud SDK.
1PushMessagingSdkModule.disablePush();void1import { PushModule } from "@sfmc/react-native-push";
2import type { PushApi } from "@sfmc/react-native-push";
3
4const push: PushApi = await PushModule.requestSdk();
5push.disablePush();Returns the current state of the push-enabled flag in the native Marketing Cloud SDK.
1PushMessagingSdkModule.isPushEnabled();Promise<boolean> - A promise that resolves to whether push messaging is enabled.1import { PushModule } from "@sfmc/react-native-push";
2import type { PushApi } from "@sfmc/react-native-push";
3
4const push: PushApi = await PushModule.requestSdk();
5const enabled = await push.isPushEnabled();Returns the token that Marketing Cloud uses to send push messages to the device.
1PushMessagingSdkModule.getPushToken();Promise<string \| null> - A promise that resolves to the push token string, or null.1import { PushModule } from "@sfmc/react-native-push";
2import type { PushApi } from "@sfmc/react-native-push";
3
4const push: PushApi = await PushModule.requestSdk();
5const token = await push.getPushToken();
6
7const sub = PushModule.getEmitter().addListener("sfmc_push_token_refreshed", ({ token }) => {
8 console.log("Token refreshed:", token);
9});
10
11sub.remove();