This section provides API reference details for the Push Messaging module in the React Native unified plugin.
enablePush
Enables push messaging in the native Marketing Cloud SDK.
Syntax
PushMessagingSdkModule.enablePush();
Returns
void
Example
import { PushModule } from "@sfmc/react-native-push";
import type { PushApi } from "@sfmc/react-native-push";
const push: PushApi = await PushModule.requestSdk();
push.enablePush();
See Also
disablePush
Disables push messaging in the native Marketing Cloud SDK.
Syntax
PushMessagingSdkModule.disablePush();
Returns
void
Example
import { PushModule } from "@sfmc/react-native-push";
import type { PushApi } from "@sfmc/react-native-push";
const push: PushApi = await PushModule.requestSdk();
push.disablePush();
See Also
isPushEnabled
Returns the current state of the push-enabled flag in the native Marketing Cloud SDK.
Syntax
PushMessagingSdkModule.isPushEnabled();
Returns
Promise<boolean>- A promise that resolves to whether push messaging is enabled.
Example
import { PushModule } from "@sfmc/react-native-push";
import type { PushApi } from "@sfmc/react-native-push";
const push: PushApi = await PushModule.requestSdk();
const enabled = await push.isPushEnabled();
See Also
getPushToken
Returns the token that Marketing Cloud uses to send push messages to the device.
Syntax
PushMessagingSdkModule.getPushToken();
Returns
Promise<string \| null>- A promise that resolves to the push token string, ornull.
Example
import { PushModule } from "@sfmc/react-native-push";
import type { PushApi } from "@sfmc/react-native-push";
const push: PushApi = await PushModule.requestSdk();
const token = await push.getPushToken();
const sub = PushModule.getEmitter().addListener("sfmc_push_token_refreshed", ({ token }) => {
console.log("Token refreshed:", token);
});
sub.remove();