Package com.cheetahdigital.referral.core
Class ReferralUtils
- java.lang.Object
-
- com.cheetahdigital.referral.core.ReferralUtils
-
public class ReferralUtils extends java.lang.Object
Helper class for saving and removing referral codes from shared preferences
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interface
ReferralUtils.FirebaseIncomingLinkListener
Listener for checking of incoming Firebase dynamic linkstatic interface
ReferralUtils.FirebaseLinkGeneratorListener
Listener for creation of Firebase dynamic link
-
Constructor Summary
Constructors Constructor Description ReferralUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static void
checkCode(android.content.Context context, android.content.Intent intent)
This checks for referral code from intent as the app is launched.static void
checkFirebaseLink(android.app.Activity activity, ReferralUtils.FirebaseIncomingLinkListener listener)
Checks for Firebase dynamic links and parses the referral codestatic java.lang.String
getCode(android.content.Context context)
static com.google.android.gms.tasks.Task<com.google.firebase.dynamiclinks.ShortDynamicLink>
getFirebaseLink(android.content.Context context, java.lang.String referralLink, java.lang.String androidPackageName, java.lang.String iOSPackageName, java.lang.String iOSAppstoreID, java.lang.String subject, java.lang.String body, ReferralUtils.FirebaseLinkGeneratorListener listener)
Generates a shortened firebase dynamic link using the given referral datastatic void
removeCode(android.content.Context context)
Removes referral code from shared preferencesstatic void
saveCode(android.content.Context context, java.lang.String code)
Saves referral code to shared prefs
-
-
-
Method Detail
-
getCode
public static java.lang.String getCode(android.content.Context context)
- Parameters:
context
- Context- Returns:
- referral code. Returns empty string if the code does not exist.
-
saveCode
public static void saveCode(android.content.Context context, java.lang.String code)
Saves referral code to shared prefs- Parameters:
context
- Contextcode
- referral code
-
removeCode
public static void removeCode(android.content.Context context)
Removes referral code from shared preferences- Parameters:
context
- Context
-
checkCode
public static void checkCode(android.content.Context context, android.content.Intent intent)
This checks for referral code from intent as the app is launched. This implementation is quite different from the one inReferralReceiver
. This is ideally called in the splash activity.- Parameters:
context
- Contextintent
- intent
-
getFirebaseLink
public static com.google.android.gms.tasks.Task<com.google.firebase.dynamiclinks.ShortDynamicLink> getFirebaseLink(android.content.Context context, java.lang.String referralLink, java.lang.String androidPackageName, java.lang.String iOSPackageName, java.lang.String iOSAppstoreID, java.lang.String subject, java.lang.String body, ReferralUtils.FirebaseLinkGeneratorListener listener)
Generates a shortened firebase dynamic link using the given referral data- Parameters:
context
-context
referralLink
- The link your app will open. You can specify any URL your app can handle, such as a link to your app's content. This link must be a well-formatted URL, be properly URL-encoded, and use the HTTP or HTTPS scheme.androidPackageName
- the Android package nameiOSPackageName
- the iOS package nameiOSAppstoreID
- the App Store ID, used to send users to the App Store when the app isn't installed.subject
- the title to use when the Dynamic Link is shared in a social post.body
- the description to use when the Dynamic Link is shared in a social post.listener
- the listener for creating a Firebase dynamic link- Returns:
Task
-
checkFirebaseLink
public static void checkFirebaseLink(android.app.Activity activity, ReferralUtils.FirebaseIncomingLinkListener listener)
Checks for Firebase dynamic links and parses the referral code- Parameters:
activity
-Activity
classlistener
- listener for checking of Firebase link
-
-