Skip to content

waseemwanologicalsolutions/SDKDocumentation

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 

Repository files navigation

Table of contents

  1. Requirements
  2. Getting Started
    1. Integration
    2. Get Organization ID and Source ID
    3. Events Tracking
    4. Get VisitorId From Framework
    5. Identifying Visitors
    6. Custom Event
    7. Disable TextCapture
    8. Disable Default Event Tracking
    9. Enable Default Event Tracking
    10. Enable Event Logging
    11. Disable Event Logging
    12. Reset Tracking Session
    13. End Tracking Session
    14. Start Tracking Session
    15. iOS14&Later and ATTTransportSecurity
    16. Privacy Location
  3. Troubleshooting
    1. Building for iOS, but the linked and embedded framework 'Intempt.framework' was built for iOS + iOS Simulator.
    2. Unsupported Architectures
    3. dyld: Library not loaded
    4. Intempt no such module found
    5. No data visible on app.intempt.com
    6. Events not sending, taking too long

Intempt iOS SDK

Requirements

  • iOS 12.0+
  • Minimum Xcode 10.0

Getting Started

Integration:

  1. At first download Intempt framework from https://github.com/intempt/ios-sdk.git). Then open the folder framework.

Intempt-1

  1. Copy Intempt.xcframework into your project directory and then Drag & Drop Intempt.xcframework in your iOS app.

Intempt-2

Intempt-3

  1. Intempt.xcframework must set to Embed & Sign, Select your project Traget -> Build Phase expand Embed Framework and press + add Intempt.xcframework

Intempt-4

Intempt-5

make sure in Target ->General->Framework, Libraries and Embded Contents Embed & Sign is selected.

Intempt-6

If you have followed the above 3 steps then you will be able to compile without any error on device or simulator.

Swift :

If Xcode 11.3 or above

Goto AppDelegate.swift file

import Intempt
    func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
        
        ///Your code here
        
        //Initialize Intempt SDK
        let intemptConfig = IntemptConfig(queueEnabled: true, withItemsInQueue: 7, withTimeBuffer: 15, withInitialDelay: 0.3, withInputTextCaptureDisabled: false)
        IntemptTracker.tracking(withOrgId: "Your Organization Id", withSourceId: "Your Source ID", withToken: "Your Token", withConfig: intemptConfig) { (status, result, error) in
            if(status) {
                if let dictResult = result as? [String: Any] {
                    print(dictResult)
                }
            }
            else {
                if let error = error {
                    print(error.localizedDescription)
                }
            }
        }
        
        return true
    }

Else you will have the ViewController.swift file and then paste the copied source snippet into the viewDidLoad function:

import Intempt
  override func viewDidLoad() {
        super.viewDidLoad()
      
	 //Initialize Intempt SDK
        let intemptConfig = IntemptConfig(queueEnabled: true, withItemsInQueue: 7, withTimeBuffer: 15, withInitialDelay: 0.3, withInputTextCaptureDisabled: false)
        IntemptTracker.tracking(withOrgId: "Your Organization Id", withSourceId: "Your Source ID", withToken: "Your Token", withConfig: intemptConfig) { (status, result, error) in
            if(status) {
                if let dictResult = result as? [String: Any] {
                    print(dictResult)
                }
            }
            else {
                if let error = error {
                    print(error.localizedDescription)
                }
            }
        }
}

Objective C :

If you are using Xcode 11.3 or above go to AppDelegate.m file and paste the copied source snippet like the following:

@import Intempt;
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Your code here
    
    //initalize intempt SDK
    IntemptConfig *intemptConfig  = [[IntemptConfig alloc]initWithQueueEnabled:YES withItemsInQueue:7 withTimeBuffer:15 withInitialDelay:0.3 withInputTextCaptureDisabled:NO];
    [IntemptTracker trackingWithOrgId:@"Your Organization Id" withSourceId:@"Your Source ID" withToken:@"Your Token" withConfig:intemptConfig onCompletion:^(BOOL status, id result, NSError *error) {
        
    }];
    
    return YES;
}

Else you will have the ViewController.m file and then paste the copied source snippet like the following:

@import Intempt
- (void)viewDidLoad {
    [super viewDidLoad];
    
     //initalize intempt SDK
    IntemptConfig *intemptConfig  = [[IntemptConfig alloc]initWithQueueEnabled:YES withItemsInQueue:7 withTimeBuffer:15 withInitialDelay:0.3 withInputTextCaptureDisabled:NO];
    [IntemptTracker trackingWithOrgId:@"Your Organization Id" withSourceId:@"Your Source ID" withToken:@"Your Token" withConfig:intemptConfig onCompletion:^(BOOL status, id result, NSError *error) {
        
    }];
}

Get Organization ID and Source ID

To get your organization Id and source Id you need to create your account on https://app.intempt.com/ and then go to https://app.intempt.com/sources/

  • 1 Create Organization
  • 2 Create Source
  • 3 Copy Source ID, Organization Id and Token in your Xcode app for IntemptSDK initialization.

Source Creation

Events Tracking

IntemptSDK track different type events, some of these are default and some are custom, default events are automatically started tracking when SDK is initialized and for custom events developer have to write code whereever required. Below types events are in IntemptSDK

  • Application Launch Tracking (Default, automatically tracked)
  • Screen Tracking (Default, automatically tracked)
  • Interaction Tracking (Default, automatically tracked)
  • Consent (Default, automatically tracked)
  • Location (Depending on application, if user of the app has allowed location permission then country, city level location is tracked)
  • Identity (Manual, Developer have to implement it)
  • Custom (Developer have to create schema and implement in app)

Get VisitorId From Framework

let visitorId = IntemptClient.shared()?.getVisitorId()

Identifying Visitors

Provide email or phone number.

IntemptTracker.identify("[email protected]", withProperties: nil) { (status, error) in 
	if(status) {
		//Do something
	}
}

Custom Event

On using this a user can create a custom event based on the need of the project and can track the event details with that custom method. To add custom event below should be flow

  • 1 Visit the Intempt Console https://app.intempt.com/sources/
  • 2 Select Organization -> Source -> Schema
  • 3 Drag 'Add collection' from the right panel(Schema Builder) to the exisiting collections list
  • 5 Drag the 'Add field' to the added collection, add as many fields as required.
  • 6 Set field type carefully e.g if the data from app is string and field type set in int then there will be error.
  • 7 If you want to link the events with the visitor session then add 'sessionId' as foreign key of 'Session' collection into that collection

Every custom event schema must have timestamp of type long and eventId of type string fields, otherwise your custom event will not be saved and you will get bad request error.

Please becarefull when renaming, Collection and Field name always start with small letter

flight-Booking Collection

let arrayData = [{       
                "flightId" : "1",
                "bookingDate" : "2020-05-26",
                "bookingId": "2",
                "bookingStatus" : "booked"
              }]
        IntemptTracker.track("flight-booking", withProperties: arrayData as? [Any]) { (status, result, error) in
            if(status) {
                if let dictResult = result as? [String: Any] {
                    print(dictResult)
                }
            }
            else {
                if let error = error {
                    print(error.localizedDescription)
                }
            }
        }
}             

Schema of above example 'flight-booking' looks like below screenshot

demo collection

Disable Text Capture

Call this method if you want to disable capturing input texts like UItextField, UItextView. By default its false. Secure entries are also excluded for privacy.

IntemptTracker.disableTextInput(true)

Disable Default Event Tracking

Call this method if you want to disable default tracking. This action is persistent, once disabled then developer must need to enable again when want to track default events again.

IntemptClient.disableTracking()

Enable Default Event Tracking

Call this method if you had disabled tracking and want to enable again.

IntemptClient.enableTracking()

Enable Event Logging

Call this method if you want to see the logs of all generated events, errors for debug purposes. By default logging is disabled

IntemptClient.enableLogging()

Disable Event Logging

Call this method if you want not see any output in console.

IntemptClient.disableLogging()

Reset Tracking Session

Call this method in order to reset tracking session. It will end previous session and start new session.

IntemptClient.shared().validateTrackingSession()

End Tracking Session

Call this method in order to end tracking session.

IntemptClient.shared().endTrackingSession()

Start Tracking Session

Call this method in order to start a new tracking session.

IntemptClient.shared().startTrackingSession()

Tracking iOS14 & later and ATTTransportSecurity framework

Intempt itself does not get IDFA and doesn't track user by default. Data is not forwarded to any external services, and is not linked with any third-party data. Also events captured are not linked to user indentity and not used for user tracking purpose. Analytic are captured to observe the user behavior, viuslations of app usage and improving user experience based on user activities in the app. So with the default configuration there is no need for adding Apple Tracking Transparency permission in info.plist and asking user consent. Also don't include Apple Tracking Transparency framework in your app. However if your app has other external integrations or you have implemented custom events which track user or share user data with other then you have to include it.

Privacy - Location Permission

IntemptSDK itself doesn't ask user for the location permission and doesn't fetch user location. However IntemptSDK has refence to CoreLocations framework and if the app(where IntemptSDK integrated) already have obtained user consent for Location then IntemptSDK track user location of city, region, country level. As the IntemptSDK has reference to CoreLocations framework so it is required to add Privacy - Location in info.plist with explaining the purpose of location fetch and usage.

Go to app's Info.plist file and add the privacy keys.

Key Value
Privacy - Location Always Usage Description Location used to track where you are and showing most relevant content to you.
Privacy - Location When In Use Usage Description Location used to track where you are and showing most relevant content to you
Privacy - Location Always and When In Use Usage Description Location used to track where you are and showing most relevant content to you

Troubleshooting

Building for iOS, but the linked and embedded framework 'Intempt.xcframework' was built for iOS + iOS Simulator.

Select your project Target -> Build Settings and search Validate Workspace Set Value to NO, if its already NO, then set to YES once and then set again to NO. This is workaround as sometimes xcode doesn't understand, so toggeling the value between YES/NO it worked.

Validate Workspace

Appstore uploading issue of invalid unsupported architectures.

Intempt.xcframework is universal and it supports Simulators and Devices both, when submitting to app store Apple may show error of simulator architectures. To resolve this issue please select your project Target -> Build Phase and select + sign and add New Run Script Phase. It will add an empty runscript below, expand it and put the below script as shown in below screen shot.

# skip if we run in debug
if [ "$CONFIGURATION" == "Debug" ]; then
echo "Skip frameworks cleaning in debug version"
exit 0
fi

APP_PATH="${BUILT_PRODUCTS_DIR}/${FRAMEWORKS_FOLDER_PATH}/"

# This script loops through the frameworks embedded in the application and
# removes unused architectures.
find "$APP_PATH" -name '*.framework' -type d | while read -r FRAMEWORK
do
FRAMEWORK_EXECUTABLE_NAME=$(defaults read "$FRAMEWORK/Info.plist" CFBundleExecutable)
FRAMEWORK_EXECUTABLE_PATH="$FRAMEWORK/$FRAMEWORK_EXECUTABLE_NAME"
echo "Executable is $FRAMEWORK_EXECUTABLE_PATH"

EXTRACTED_ARCHS=()

for ARCH in $ARCHS
do
echo "Extracting $ARCH from $FRAMEWORK_EXECUTABLE_NAME"
lipo -extract "$ARCH" "$FRAMEWORK_EXECUTABLE_PATH" -o "$FRAMEWORK_EXECUTABLE_PATH-$ARCH"
EXTRACTED_ARCHS+=("$FRAMEWORK_EXECUTABLE_PATH-$ARCH")
done

echo "Merging extracted architectures: ${ARCHS}"
lipo -o "$FRAMEWORK_EXECUTABLE_PATH-merged" -create "${EXTRACTED_ARCHS[@]}"
rm "${EXTRACTED_ARCHS[@]}"

echo "Replacing original executable with thinned version"
rm "$FRAMEWORK_EXECUTABLE_PATH"
mv "$FRAMEWORK_EXECUTABLE_PATH-merged" "$FRAMEWORK_EXECUTABLE_PATH"

done

10

dyld: Library not loaded: @rpath/Intempt.xcframework/Intempt

Intempt.xcframework must set to Embed & Sign

Intempt-6

Intempt no such module found

Sometimes xcode behaves strange and not link properly, so first delete Intempt.xcframework from your project, clean build and delete Drived Data then again follow belwo steps to add framework

Open folder containg Intempt.xcframework and first copy Intempt.xcframework into your project directory and then Drag & Drop Intempt.xcframework in your iOS app.

Intempt-2

Intempt-4

Intempt.xcframework must set to Embed & Sign, Select your project Traget -> Build Phase expand Embed Framework and press + add Intempt.xcframework

Screenshot 2021-12-03 at 12 04 13 PM

make sure in Target ->General->Framework, Libraries and Embded Contents Embed & Sign is selected.

Intempt-6

No data visible on app.intempt.com console dashboard

For performance and efficiency purpose IntemptSDK send events as batch periodically, it may take few seconds to appear your events on console.

Events not sending, taking too long

if you see your events are captured and shown in log in debug mode but sent too late on intempt server, then in such case you need to check two below things in your intemptSDK initalization.

  • `TimeBuffer' its value is in seconds, if sdk send data to server periodically based on value of this parameter
  • ItemsInQueue its value is number of events, if you set value to 10, IntemptSDK will wait untill 10 or more events are captured then it sends

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published