There are 2 steps involved in adding the sharpsell SDK in your project.
Download the XCFramework from the link which is given by Sharpsell team and unzip it.
You will find debug and release folders. Inside the folders you will find the below xcframeworks
In order to run in iOS Simulators, we need to use debug version.So, if you are testing the app in simulator then use XCFramrworks which is available in Debug Folder.
Use XCFrameworks which is in Release folder when sharing a build or release the app to the app store. Debug frameworks will be slower compare with release framework.
Drag and drop all four XCFramework in Framework, Libraries and Embedded content section in project settings for your app target. All the frameworks will be added as Embed & Sign framework by default.
Make sure all other framework are in Embed & Sign .
Note: - Not supported in 2.5.1 version due to local depdency failures. We will be fixing this in the version.
In order to run in iOS Simulators, we need to use debug version.So, if you are testing the app in simulator then use XCFramrworks which is available in Debug Folder and replace those into the project as mentioned above.
Note: Make sure we are using release frameworks when sharing a build or release the app to the app store. Debug frameworks will be slower compare with release framework.
Note: Import SharpsellCore
in the class or struct where ever you are trying access Sharpsell.
Make sure to call createSmartSellEngine
and then initialize
before calling any other SDK
functions.
This function used to initialise the object required by the SDK - So we its better to call this
function on app start preferably in didFinishLaunchingWithOptions
function in AppDelegate
class.
Sharpsell.services.createFlutterEngine()
The SDK has to be initialized before calling any other methods of the SDK. On calling
the Sharpsell.initialize
method, a success or failure status will be returned via a callback.
Sample code on how to initialize the SDK is given below.
/* Initialize Sharpsell
*
* coreSdk -
* country_code, user_meta, name, mobile_number, email is nullable
* Rest of the fields are required when the app is run as a SDK
* */
// Note - If you don't have any of the below data then don't pass null, just pass empty strings
let initSharpsellData: [String:Any] = [
"company_code": "sample_sdk", // Company code given to you by sharpsell team
"user_unique_id": "88888888888", // Mobile number of the user which you want to login into sharpsell
"user_group_id": "1", // User Group ID given to you by sharpsell team
"country_code": "",
"user_meta": "", // If you have user meta, pass those as a string
"name": "Surya", // User Name
"mobile_number": "888888888", // User mobile number
"email": "[email protected]", // User Email Id
"fcm_token": firebaseToken] // Firebase token which is generated
//To generate firebase token, please follow firebase documentation for iOS
Sharpsell.services.initialize(smartsellParameters: initSharpsellData) {
//Flutter initialized succecfully
} onFailure: { (errorMessage, smartsellError) in
switch smartsellError {
case .flutterError:
debugPrint("Error Message: \(errorMessage)")
case .flutterMethodNotImplemented:
debugPrint("Error Message: Flutter Method Not Implemented")
default:
debugPrint("Error Message: UnKnown Error in \(#function)")
}
}
Sharpsell.services.open(arguments: ""){ (flutterViewController) in
self.navigationController?.pushViewController(flutterViewController, animated: true)
} onFailure: { (errorMessage, smartSellError) in
switch smartSellError {
case .flutterError:
debugPrint("Error Message: \(errorMessage)")
case .flutterMethodNotImplemented:
debugPrint("")
default:
debugPrint("")
}
}
let presentationArgs = ["route" : "productPresentationInput",
"presentation_name" : presentationInputName,
"input_one" : presentationInputOne,
"input_two" : presentationInputTwo]
if let sharpsellDict = presentationArgs {
sharpsellOpenDataInString = Sharpsell.services.convertJsonToString(dict: sharpsellDict)
}
Sharpsell.services.open(arguments: sharpsellDict){ (flutterViewController) in
self.navigationController?.pushViewController(flutterViewController, animated: true)
} onFailure: { (errorMessage, smartSellError) in
switch smartSellError {
case .flutterError:
debugPrint("Error Message: \(errorMessage)")
case .flutterMethodNotImplemented:
debugPrint("")
default:
debugPrint("")
}
}
let launchpadArgs = ["route" : "launchpad"]
if let sharpsellDict = launchpadArgs {
sharpsellOpenDataInString = Sharpsell.services.convertJsonToString(dict: sharpsellDict)
}
Sharpsell.services.open(arguments: sharpsellDict){ (flutterViewController) in
self.navigationController?.pushViewController(flutterViewController, animated: true)
} onFailure: { (errorMessage, smartSellError) in
switch smartSellError {
case .flutterError:
debugPrint("Error Message: \(errorMessage)")
case .flutterMethodNotImplemented:
debugPrint("")
default:
debugPrint("")
}
}
let mcDirArgs = ["route" : "mcDirectory"]
if let sharpsellDict = mcDirArgs {
sharpsellOpenDataInString = Sharpsell.services.convertJsonToString(dict: sharpsellDict)
}
Sharpsell.services.open(arguments: sharpsellDict){ (flutterViewController) in
self.navigationController?.pushViewController(flutterViewController, animated: true)
} onFailure: { (errorMessage, smartSellError) in
switch smartSellError {
case .flutterError:
debugPrint("Error Message: \(errorMessage)")
case .flutterMethodNotImplemented:
debugPrint("")
default:
debugPrint("")
}
}
let potdArgs = ["route" : "potd"]
if let sharpsellDict = potdArgs {
sharpsellOpenDataInString = Sharpsell.services.convertJsonToString(dict: sharpsellDict)
}
Sharpsell.services.open(arguments: sharpsellDict){ (flutterViewController) in
self.navigationController?.pushViewController(flutterViewController, animated: true)
} onFailure: { (errorMessage, smartSellError) in
switch smartSellError {
case .flutterError:
debugPrint("Error Message: \(errorMessage)")
case .flutterMethodNotImplemented:
debugPrint("")
default:
debugPrint("")
}
let dvcArgs = ["route" : "dvc"]
if let sharpsellDict = dvcArgs {
sharpsellOpenDataInString = Sharpsell.services.convertJsonToString(dict: sharpsellDict)
}
Sharpsell.services.open(arguments: sharpsellDict){ (flutterViewController) in
self.navigationController?.pushViewController(flutterViewController, animated: true)
} onFailure: { (errorMessage, smartSellError) in
switch smartSellError {
case .flutterError:
debugPrint("Error Message: \(errorMessage)")
case .flutterMethodNotImplemented:
debugPrint("")
default:
debugPrint("")
}
let tcHomeArgs = ["route" : "tcHome"]
if let sharpsellDict = tcHomeArgs {
sharpsellOpenDataInString = Sharpsell.services.convertJsonToString(dict: sharpsellDict)
}
Sharpsell.services.open(arguments: sharpsellDict){ (flutterViewController) in
self.navigationController?.pushViewController(flutterViewController, animated: true)
} onFailure: { (errorMessage, smartSellError) in
switch smartSellError {
case .flutterError:
debugPrint("Error Message: \(errorMessage)")
case .flutterMethodNotImplemented:
debugPrint("")
default:
debugPrint("")
}
let productBundleArgs = ["route" : "productBundle"]
if let sharpsellDict = productBundleArgs {
sharpsellOpenDataInString = Sharpsell.services.convertJsonToString(dict: sharpsellDict)
}
Sharpsell.services.open(arguments: sharpsellDict){ (flutterViewController) in
self.navigationController?.pushViewController(flutterViewController, animated: true)
} onFailure: { (errorMessage, smartSellError) in
switch smartSellError {
case .flutterError:
debugPrint("Error Message: \(errorMessage)")
case .flutterMethodNotImplemented:
debugPrint("")
default:
debugPrint("")
}
let quickLinksArgs = ["route" : "quickLinks"]
if let sharpsellDict = quickLinksArgs {
sharpsellOpenDataInString = Sharpsell.services.convertJsonToString(dict: sharpsellDict)
}
Sharpsell.services.open(arguments: sharpsellDict){ (flutterViewController) in
self.navigationController?.pushViewController(flutterViewController, animated: true)
} onFailure: { (errorMessage, smartSellError) in
switch smartSellError {
case .flutterError:
debugPrint("Error Message: \(errorMessage)")
case .flutterMethodNotImplemented:
debugPrint("")
default:
debugPrint("")
}
Make sure the Sharpsell.services.clearData
is called when the user is logging out of the
application.
Sharpsell.services.clearData {
//Handle logut success
} onFailure: { message, errorType in
//Logut Failed
}
link |
Stars: 0 |
Last commit: 2 weeks ago |
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics