Class ReferralUtils


  • public class ReferralUtils
    extends java.lang.Object
    Helper class for saving and removing referral codes from shared preferences
    • 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 code
      static 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 data
      static void removeCode​(android.content.Context context)
      Removes referral code from shared preferences
      static void saveCode​(android.content.Context context, java.lang.String code)
      Saves referral code to shared prefs
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • ReferralUtils

        public ReferralUtils()
    • 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 - Context
        code - 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 in ReferralReceiver. This is ideally called in the splash activity.
        Parameters:
        context - Context
        intent - 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 name
        iOSPackageName - the iOS package name
        iOSAppstoreID - 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 class
        listener - listener for checking of Firebase link