Integration

Add InviteReferrals Library to your Project

flutter pub add flutter_invitereferrals  

Link library to Project

flutter pub get

Cocoapods (For iOS Apps)

To complete the linking, it's necessary to install pods (via Cocoapods) on a Mac while integrating for iOS.

cd ios && pod install && cd ..

Initialize SDK (Platform Specific)

ANDROID

Configure your AndroidManifest.xml

<manifest….>        
   <uses-permission android:name="android.permission.INTERNET" />
   <uses-permission android:name="android.permission.WAKE_LOCK" />
   <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
   <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
   <uses-permission android:name="android.permission.CHANGE_NETWORK_STATE" />
   <uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
   <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
   <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
      <application>                 
         <meta-data           
           android:name="invitereferrals_bid"
           android:value="10xxx" />
         <meta-data
           android:name="invitereferrals_bid_e"
           android:value="C2C3xxxxxxxxxxxxxxxxxx" />
       </application>
    </manifest>

📘

Note

In the above example, Dummy Brand ID and Encryption keys shown. Kindly login your IR_account to see your credentials.

Application Class initialization

A. If you have your own Application class, Then follow this step Otherwise, Skip this step and follow Step B.

Imported this statement

import com.flutter.invitereferrals.InviteReferralsPlugin;

Call this method in the onCreate() method.

InviteReferralsPlugin.register(this);

B. If you don’t have your Application class. Then add this line to your manifest.xml.

android:name="com.invitereferrals.invitereferrals.InviteReferralsApplication"

iOS

Configure info.plist file

To configure your info.plist, go to iOS folder inside your Flutter Project Folder and open your iOS project into Xcode by double click on .xcworkspace file and once your flutter iOS project is open into Xcode Goto info.plist, open info.plist file as source code (right-click on info.plist and click on Open as >> Source code) and add the following code in it.

<key>CFBundleURLTypes</key>
  <array>
        <dict>
      <key>CFBundleURLName</key>
     	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>
             	<key>CFBundleURLSchemes</key>
             	<array>
 	<string>”yourURLscheme comes here”</string>
         </array>
     	</dict>
          </array>
<key>LSApplicationQueriesSchemes</key>
	<array>
		<string>whatsapp</string>
		<string>fb</string>
		<string>twitter</string>
	</array>

OR

You can simply open the 'info.plist' file as 'Property List' and add the keys which work the same as above.

  1. Add a new row again and set up a URL Types item by means of adding a new item. Expand the URL Types key, then expand Item 0, and add a new item, URL Identifier . Fill in 'appScheme' for Item 0 of URL schemes and your company identifier for the URL Identifier. Once done, your file should resemble the image provided below.
  1. Add a new row again and set up a LSApplicationQueriesSchemes as an Array. Fill in 'whatsapp' for Item 0 , 'fb' for item 1 and 'twitter' for item 2 as illustrated in the image provided below.

Import Header File

Objective-C:

Import the InviteReferrals header file in each file in which the SDK function is to be accessed as given below.

Swift:

If your project IOS platform is in Swift language then you have to create a Bridging-Header.h file.
In this file you can import Invitereferrals SDK to use it in your project's swift files. To do so add a new header file and name it as per the following format. YOUR_FLUTTER_IOS_PROJECT_NAME-Bridging-Header.h

For example, if your project name is Runner. Then the header file name will be Runner-Bridging-Header.h. Now add the following import statement in YOUR_FLUTTER_IOS_PROJECT_NAME-Bridging-Header.h for accessing SDK Classes.

📘

Note

Make sure that the path of bridge-header.h file is included in build settings under 'Swift compiler-code generation' as: Objective C bridging header: YOUR_FLUTTER_IOS_PROJECT_NAME/YOUR_FLUTTER_IOS_PROJECT_NAME-Bridging-Header.h

#import "InviteReferrals.h"
#import "InviteReferrals.h"

Initialize SDK into the App Delegate file

Initialize the SDK in didFinishLaunchingWithOptions function.

[[InviteReferrals sharedInstance] setupWithBrandId: BRANDID encryptedKey: @"ENCRYPTEDKEY"];

//Example
- (BOOL)application:(UIApplication *)application
didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
   [GeneratedPluginRegistrant registerWithRegistry:self];
   // Override point for customization after application launch.
   [InviteReferrals sharedInstance] setupWithBrandId: 10XXX encryptedKey: @"C2C3B406726C2F12F440XXXXXXXXXXXX"];
   return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
InviteReferrals.sharedInstance().setup(withBrandId: BRANDID, encryptedKey: "ENCRYPTEDKEY")

//Example

func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
	InviteReferrals.sharedInstance().setup(withBrandId: 10XXX, encryptedKey: "C2C3B406726C2F12F440XXXXXXXXXXXX”)
  return true
 }

📘

Note

In the above example, Dummy Brand ID and Encryption keys shown. Kindly login your IR_account to see your credentials.

Add the following functions in your AppDelegate file. openURL function that will check the deep linking and open your app from the URL Scheme.

[[InviteReferrals sharedInstance] openUrlWithUrl: url];

// Example (Deep Link)
-(BOOL)application:(UIApplication *)app openURL:(NSURL *)url options:(NSDictionary<UIApplicationOpenURLOptionsKey,id> *)options {
   [[InviteReferrals sharedInstance] openUrlWithUrl: url];
    return  nil;
}


[[InviteReferrals sharedInstance] continueUserActivityWith: userActivity];

//Example (Universal Links)
-(BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray<id<UIUserActivityRestoring>> * _Nullable))restorationHandler {
  [[InviteReferrals sharedInstance] continueUserActivityWith: userActivity];
 return YES;
}
InviteReferrals.sharedInstance().openUrl(with: url)

//Example (Deep Link)
func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
     InviteReferrals.sharedInstance().openUrl(with: url)
     return true
}


InviteReferrals.sharedInstance().continueUserActivity(with: userActivity)

//Example (Universal Links)
func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
  InviteReferrals.sharedInstance().continueUserActivity(with: userActivity)
return true
}

Import inviteReferrals Package

Now in your code import the inviteReferrals package

import 'package:flutter_invitereferrals/flutter_invitereferrals.dart';