LogoLogo
  • Home
  • Integration & SDKs
    • Web / Browser Push
      • Wordpress Integration Steps
      • Wix Integration Steps
      • Safari
        • Safari on Desktop
        • Safari on Mobile (iOS / iPadOS)
      • SDK
        • SDK Methods
        • SDK Events
        • Customizing Prompt CSS
        • AMP Support
        • E-Commerce / Abandoned Cart
    • Native App Push
      • Apple / iOS
        • P8 Key or P12 Cert Setup
        • SDK: Swift / Obj-C
          • Activity Tracking
          • Deep Linking
          • Live Activities
          • App Messages
          • Identity Synchronization
          • SDK Methods
          • SDK Delegates
        • SDK: React Native
        • SDK: Flutter
        • Advanced
          • Self-Managed Integration
        • iOS SDK Changelog
      • Android
        • Firebase App Setup
        • SDK: Kotlin / Java
          • Deep Linking
          • Activity Tracking
          • App Messages
          • Identity Synchronization
          • SDK Methods
          • SDK Callbacks
          • Live Activities
        • SDK: React Native
        • SDK: Flutter
        • Advanced
          • Self-Managed Integration
        • Android SDK Changelog
      • React Native
        • Android: Firebase App Setup
        • iOS: P8 Key or P12 Cert Setup
        • SDK: React Native
          • Deep Linking
          • Activity Tracking
          • Subscriber Matching
          • Live Activities
          • App Messages
          • SDK Methods
      • Flutter
        • Android: Firebase App Setup
        • iOS: P8 Key or P12 Cert Setup
        • SDK: Flutter
          • Deep Linking
          • Activity Tracking
          • Subscriber Matching
          • Live Activities
          • App Messages
          • SDK Methods
  • API
    • API Access Management
    • API Reference
  • Platform
    • Dashboard
    • Notifications
      • A/B Testing
      • Custom Buttons
      • Notification Previews
      • Inline Segmentation
      • Notification Templates
      • Macros
      • Native App Push Notifications
    • App Messages
    • Segments
      • Custom Geo Segmentation
    • Campaigns
    • Insights
    • User Management
    • Organizations
      • Multi-Factor Authentication
      • Single Sign On
        • Google Workspace
        • Microsoft Azure AD
        • Okta Workforce
      • Multi-Domain Notifications
      • Multi-Domain Segments
      • API Access
    • Multi-Channel Notifications
  • Info Center
    • Launch Guide & Best Practices
      • Landing Domain Whitelist
    • Web / Browser Push
      • Common Questions
      • Browser Support
      • Retrieve Push User ID
      • Not Getting Prompted
      • Not Receiving Notifications
      • How to Unsubscribe
    • Native App Push
      • Retrieve Push User ID
    • Workflow Planning
Powered by GitBook
On this page
  • Manually Triggering the Permission Dialog
  • Adding Attributes to a Subscriber's Profile
  • Activity Tracking (URL / Screen Visits)
  • Retrieving Your Anonymous Push ID
  • Setting the Subscriber's External ID
  • Determining if a Visitor is Already Subscribed
  • Determining if a Visitor is Eligible to Prompt
  • Permanently Delete a User
  • Setting the SDK Log Level
  1. Integration & SDKs
  2. Native App Push
  3. React Native
  4. SDK: React Native

SDK Methods

Manually Triggering the Permission Dialog

You may choose to disable automatic triggering of the permission dialog via the platform. In this scenario you would choose to trigger the dialog based on your own criteria (eg: after a visitor interacts with a modal / soft prompt, visits a specific screen/page, etc).

The following code will manually trigger the dialog:

const { granted } = await PushSDK.showNativeNotificationPermissionPrompt();
console.log(`User accepted permissions: ${granted}`);

Adding Attributes to a Subscriber's Profile

You can add attributes to a subscriber's profile and later perform segmentation based on those attributes. For example, you may want to tag visitors who are interested in a specific type of news (eg: politics, sports) so that you can target them with specific notifications.

PushSDK.UserProfile.set("interests", ["politics", "news"]);

If you want to set more than one attribute at a time you can also send a map of values. The following example sets both a is_paying_subscriber and interests attribute on the subscriber.

PushSDK.UserProfile.set({
  is_paying_subscriber: true,
  interests: ["politics", "news"]
});

Properties set via PushSDK.UserProfile.append() will only store the most recent 20 values provided.

Activity Tracking (URL / Screen Visits)

To track the subscriber flow through your application you can use activity tracking. You can track via screen or URL and pass associated metadata/tags if desired.

This information can then be used in segmentation to create cohorts of subscribers that have visited specific URLs or screens with tags based on number of visits and recency. For example: "Subscribers who have visited a page/screen tagged with "Astrology" at least 4 times in the last 30 days".

To track a URL or screen visited along with the keyword/tag metadata:

PushSDK.UserProfile.trackActivity("myapp://dashboard", ["my-tag"]);

Or if there are no tags to be provided omit the tags parameter:

PushSDK.UserProfile.trackActivity("https://www.pushly.com/article-1");

Retrieving Your Anonymous Push ID

The PushSDK automatically assigns an anonymous Push ID for event tracking and debugging purposes.

Run the following code to return the Push ID:

const pushId = await PushSDK.UserProfile.getAnonymousId();

Setting the Subscriber's External ID

Providing a unique User ID for your subscriber allows you to later interact with that subscriber via the API.

Once a subscriber's external ID has been set you may work with our team to set up bi-directional automated data syncs. The following use cases are common ways that publishers use the external ID via server-to-server requests:

  • Sending notifications to individual subscribers programmatically

  • Processing unsubscribe requests

  • Adding and removing profile attributes and events to subscribers

PushSDK.UserProfile.setExternalId("external-id");

You can also check to see if the subscriber is already tagged with an External ID:

const currentExternalId = await PushSDK.UserProfile.getExternalId();

Determining if a Visitor is Already Subscribed

If you need to know if a user is already subscribed to notifications the following snippet can be used:

const subscribed = await PushSDK.UserProfile.getIsSubscribed();

Determining if a Visitor is Eligible to Prompt

const isEligible = await PushSDK.UserProfile.getIsEligibleToPrompt();

Permanently Delete a User

If the user should be excluded from all notifications and tracking run the following method:

PushSDK.UserProfile.requestUserDeletion();

Setting the SDK Log Level

The PushSDK log level is set to NONE by default. Supported log levels are: VERBOSE, DEBUG, INFO, WARN, ERROR, CRITICAL, and NONE.

To enable more detailed logging add the following code in your application's index.tsx or app.tsx file:

PushSDK.setLogLevel(LogLevel.INFO);
PreviousSubscriber MatchingNextFlutter

Last updated 9 months ago