If you have an existing integration, either with the original Nudge Plus library, which always includes location-based messaging, or the newer Nudge Base + Nudge Geo combination, this guide documents how to refactor that to utilize the new Larky v4 nudge® library. You can also review the full integration guide here. The new library is compatible with apps that utilize location-based messaging as well as those that do not, and simplifies managing app builds when both options are offered.
Overall, this new architecture is simpler to implement and maintain over the long term.
We're here to help!
Have questions regarding how to refactor your current integration? Just reach out to us through the Submit a request link above, or email us at support@larky.com.
Refactoring an iOS integration
First, update your Podfile with the current library details
In your Podfile, change the nudge library and version to the latest references, replacing <LIB_VERSION_NUMBER> with the current version number:
4.2.1
pod 'nudge', '<LIB_VERSION_NUMBER>'
Run the following commands to make sure the nudge library has been updated:
pod install pod update
Add a key/value pair to indicate the type of integration
Where you initialize nudge, add this key/value pair to the options parameter based on the functionality of nudge that you need.
If using location
This would typically apply to the original Nudge Plus (2.1.X or lower) library, or the Nudge Geo library.
“nudgeVersion”: Nudge.NudgeVersion.nudgeGeo
If not using location
This would be for Nudge Base integrations.
“nudgeVersion”: Nudge.NudgeVersion.nudgeStandard
The following key/value pairs are now optional and can be removed from the initialization of nudge
Each of these original initialization parameters has been replaced with discreet function calls to give you the greatest control over your app flow.
showLocationDialog
See this guide for details regarding location permission in the new library.
federationId
See this guide for to see how to pass the Federation ID value back to the new library.
enabled
See this guide for details on enabling or disabling nudge messaging in the new library.
For Nudge Base / Nudge Geo specifically
Locate the following lines in your application, if you are using them, and update their calls from the class NudgeBase or NudgeGeo to call the Nudge class instead.
- Nudge.registerForPushNotifications()
- Nudge.NudgeErrors.unsupportediOSVersion
- Nudge.onRegisteredForNotifications(deviceToken: deviceToken)
- Nudge.onFailedToRegisterForNotifications(error:error)
- Nudge.receivedPush(notificationPayload:userInfo, application: application)
- Nudge.tappedNotification(notification: response.notification)
Refactoring an Android integration
First, update your build.gradle with the current library details
In your build.gradle file, update the dependency reference to the current version of the new nudge library:
releases.com.larky:nudge:4.2.2
For Nudge Base / Nudge Geo integrations, update the library references
In the file(s) where you import Nudge Base and / or Nudge Geo, replace those import statements with this:
import com.larky.nudge.Nudge
Where you initialize nudge replace your Nudge Base or Nudge Geo Builder object with a NudgeBuilder object like this:
myNudge = Nudge.NudgeBuilder()
Add a builder method to the NudgeBuilder() object to set the appropriate type of integration
If using location
This would typically apply to the original Nudge Plus (3.6.X or lower) library, or the Nudge Geo library.
.setNudgeVersion(Nudge.NudgeVersion.NUDGE_GEO)
If not using location
This would be for Nudge Base integrations.
.setNudgeVersion(Nudge.NudgeVersion.NUDGE_STANDARD)
The following builder methods are now optional for NudgeBuilder() and can be removed if you are using the corresponding new modular functions
.setPromptPushNotifications()
See this guide for details regarding prompting for notification permission in the new library.
.setDisclosureDialogEnabled(), .setBackgroundDisclosureDialogEnabled(), .setPersistentNotificationTitle(), .setPersistentNotificationText()
See this guide for details regarding location permission in the new library.
.setUserFederationId()
See this guide for to see how to pass the Federation ID value back to the new library.
.setEnabled()
See this guide for details on enabling or disabling nudge messaging in the new library.
Comments
0 comments
Article is closed for comments.