Last modified September 18, 2024 by Shelly Wolfe

React Native SDK upgrade guide

This guide provides information about how you can upgrade to the latest Swrve React Native SDK Plugin. For information about the changes that have been made in each React Native SDK release, see React Native SDK release notes.

To upgrade to the latest version of the Swrve React Native SDK plugin, replace the react-native-swrve-plugin folder in your project with the one found in latest release on GitHub. Or use the following command:

npm update react-native-swrve-plugin

Updating native SDK dependencies

When you add the updated folder to your project, we recommend clearing your node_modules folder and perform an npm install to ensure you have the latest SDK dependency changes. Also, if you’re using iOS, ensure you run pod update in the ios folder.


Version 7.0.0

Native app code should be upgraded according to the upgrade guides for iOS v10.0.0 and Android v12.0.0.

Legacy Architecture: The React Native legacy architecture is now deprecated. A console warning will be displayed when using the legacy architecture. While no immediate code changes are required, you should plan to migrate to the React Native New Architecture as support for the legacy architecture will be removed in a future version

This section provides information for upgrading to Swrve React Native SDK Plugin v7.0.0. The following tables list the methods and types that have been changed or deprecated.

Changed To
StringMap type The StringMap type is now deprecated. Use Record<string, string> instead. StringMap remains supported for backward compatibility but will be removed in v8+
refreshCampaignsAndResources The refreshCampaignsAndResources API is now deprecated. Use refreshContent instead which provides callback support for completion status. The deprecated method will be removed in v8+
Embedded Campaign API parameter types Methods now use Record<string, string> for personalization instead of any. Return types changed from any[] to SwrveEmbeddedMessage[]
Message Center API parameter types Methods now use Record<string, string> for personalization instead of any. Return types changed from any[]/any to SwrveMessageCenterCampaign[]/SwrveMessageCenterCampaign
InAppMessage listener signature Changed from (action: string, message: any, selectedButton?: any) to (action: SwrveMessageAction, message: SwrveMessageDetails, selectedButton?: SwrveMessageButtonDetails)
IapReward interface properties Changed from single-element tuples to arrays: items: IapRewardItems[] and currencies: IapRewardCurrencies[]
SwrvePushInboxMessage and related methods All message ID types consistently use number (previously had inconsistent bigint/number types)
Void-returning methods Methods like stopTracking, showMessageCenterCampaign, removeMessageCenterCampaign, markMessageCenterCampaignAsSeen, markEmbeddedMessageCampaignAsSeen now correctly return Promise<void> instead of Promise<any>

TypeScript Migration Notes:

  • Embedded Campaign APIs: Methods like getEmbeddedMessageCenterCampaigns() now return SwrveEmbeddedMessage[] with full type definitions
  • Message Center APIs: Methods like getMessageCenterCampaigns() now return SwrveMessageCenterCampaign[] with full type definitions
  • Personalization Parameters: All methods accepting personalization now expect Record<string, string> instead of any
  • InAppMessage Listener: Update callback implementations to use the new typed parameters for better autocomplete and type checking
  • IAP Rewards: If using IAP rewards, the interface now properly supports multiple items and currencies as arrays
  • Push Inbox: Message ID types are now consistently number throughout the API

Version 6.0.0

Native app code should be upgraded according to the upgrade guides for iOS v10.0.0 and Android v11.0.0.


Version 5.1.0

There are no code changes required to upgrade to Swrve React Native SDK Plugin v5.1.0.


Version 5.0.1

There are no code changes required to upgrade to Swrve React Native SDK Plugin v5.0.1.


Version 5.0.0

This section provides information for upgrading to Swrve React Native SDK Plugin v5.0.0. The following table lists the methods and fields that have been added.

Removed Summary
Removed SwrveMessageListeners param (which includes customButtonPressedListener, dismissButtonPressedListener and clipboardButtonPressedListener) from SwrveSDK.setListeners. Use SwrveSDK.setInAppMessageListener instead.
Removed SwrveEmbeddedMessageCampaignListener param from SwrveSDK.setListeners. Use SwrveSDK.setEmbeddedCampaignListener instead.
Removed campaign subject field from Message Center. Use messageCenterDetails.subject instead.

 


Version 4.1.3

There are no code changes required to upgrade to Swrve React Native SDK Plugin v4.1.3.


Version 4.1.2

There are no code changes required to upgrade to Swrve React Native SDK Plugin v4.1.2.


Version 4.1.1

There are no code changes required to upgrade to Swrve React Native SDK Plugin v4.1.1.


Version 4.1.0

This section provides information for upgrading to Swrve React Native SDK Plugin v4.1.0.

The following table lists the methods and fields that have been changed or added.

Changed To
MessageCustomButtonPressedListener The MessageCustomButtonPressedListener API is now deprecated. Please use InAppMessageListener instead to get campaign and button metadata.
MessageDismissButtonPressedListener The MessageDismissButtonPressedListener API is now deprecated. Please use InAppMessageListener instead to get campaign and button metadata.
MessageClipboardButtonPressedListener The MessageClipboardButtonPressedListener API is now deprecated. Please use InAppMessageListener instead to get campaign and button metadata.
EmbeddedMessageCampaignListener The EmbeddedMessageCampaignListener API is now deprecated. Please use EmbeddedCampaignListener which adds a boolean: isControl for campaign holdouts.
Added Summary
DeeplinkListener Implement this listener to handle deeplinks in the JS layer.
embeddedControlMessageImpressionEvent Use this method to send an impression event for control embedded campaigns.

 


Version 4.0.1

There are no code changes required to upgrade to Swrve React Native SDK Plugin v4.0.1.


Version 4.0.0

This section provides information for upgrading to Swrve React Native SDK Plugin v4.0.0. The following table lists the methods and fields that have been added.

Added Summary
New string argument to the MessageCustomButtonPressedListener function containing the campaign name. If your integration uses the MessageCustomButtonPressedListener, add the campaign name argument as the last item in the signature.
New string argument to the MessageDismissButtonPressedListener function containing the campaign name. If your integration uses the MessageDismissButtonPressedListener, add the campaign name argument as the last item in the signature.

 


Previous versions

If you are upgrading from a version older than 4.0.0, please refer to the React Native integration guide.