Learn how to quickly Install, Integrate & Implement the Gamize iOS SDK
Gamize iOS SDK can be integrated to any iOS project through CocoaPods. You can refer Cocoapods for more details.
Command to install CocoaPods (If it is not installed on your OS X)
$ sudo gem install cocoapods
To integrate Gamize iOS SDK into your Xcode project using CocoaPods(Use the version number provided to you), specify it in your Podfile
:
pod 'OnMobileGamification', 'x.x.x'
Then, run the following command on your project path:
$ pod install
or
$ pod install --repo-update
If, you see the below error :
[!] CocoaPods could not find compatible versions for pod "OnMobileGamification":
In Podfile:
OnMobileGamification (<x.x.x>)
None of your spec sources contain a spec satisfying the dependency: `OnMobileGamification (<x.x.x>)`.
Please, do run the below commands:
$ pod repo update
$ pod install
Import OnMobileGamification
import OnMobileGamification
It is mandatory to register the app bundle identifier with the sdk before using it.
Initialization method to start using the framework.
static func initialize(
with authKey: String,
and userKey: String,
languageCode: String = "en",
for environment: APIEnvironment = .production,
succedded success: @escaping (() -> ()),
failed fail: @escaping ((GamificationError) -> ()))
- authKey : Provide the authentication key to intialize the sdk
- userKey : Provide the user token to initialize and to connect to fetch the rewards for the user
- languageCode : Provide the language code to see the content in that localization
- success : It is a callback to handle the successfull initialization
- fail : It is a callback to handle the failure of initialization, provides the detailed error to handle
Provides next user active template details
static func nextTemplateDetail(
succedded success: @escaping ((GamificationClientCallback) -> ()),
failed fail: @escaping ((GamificationError) -> ()))
- success : It is a sucess callback with the required details of next template details in GamificationClientCallback object
- fail : It is a callback to handle the failure of next active template api, provides the detailed error to handle
Provides the user active template detailed view to proceed further gamification of particular type.
static func openRewardViewWithUIKit(
name: String,
viewDisplayType : ViewDisplayType.popup,
viewController : UIViewController,
didPresent: Binding<Bool> = .constant(false),
_ handler: @escaping ((GamificationClientHandler) -> ())) -> some View
- name : Provide the rule name to fetch the details
- viewDisplayType : Provide the viewDisplayType to decide the appearance(popup or fullscreen)
- viewController : Provide the viewController to display the reward view
- didPresent : Provide the state value when to present or dismiss the template. If true presents the template
- handler : It is a callback to handle further on client side, for detailed info please check GamificationClientHandler
static func openRewardViewWithSwiftUI(
name: String,
viewDisplayType : ViewDisplayType.popup,
didPresent: Binding<Bool> = .constant(false),
_ handler: @escaping ((GamificationClientHandler) -> ())) -> some View
- name : Provide the rule name to fetch the details
- viewDisplayType : Provide the viewDisplayType to decide the appearance(popup or fullscreen)
- didPresent : Provide the state value when to present or dismiss the template. If true presents the template
- handler : It is a callback to handle further on client side, for detailed info please check GamificationClientHandler
Provides leaderboard details for the provide rule name
static func leaderBoardFor(
_ name: String,
didPresent: Binding<Bool> = .constant(false)) -> some View
- name : Provide the rule name to fetch the details
- didPresent : Provide the state value when to present or dismiss the template. If true presents the leadeboard
Provides Reward history list details
static func getRewardHistoryList(
pageSize: Int,
pageNumber: Int,
succedded success: @escaping ((RewardHistory) -> ()),
failed fail: @escaping ((GamificationError) -> ()))
- pageSize : Provide the pageSize to determined response count in one page.
- pageNumber : Provide the pageNumber to get the number of response page by page
- succedded : It is a callback to handle the successfull response
- fail : It is a callback to handle the failure of methos, provides the detailed error to handle
This is a client handler class to perform the actions based on framework responses.
var callBackInfo: GamificationClientCallback?
Provides the extra information required to handle or know the detailed info
var callBackListenerType: GamificationCallBackListenerType?
Provides the detail of call back type
var eventListenerType: GamificationEventListenerType?
Provides the detail of event type
func dismiss()
Dismisses the SDK/Framework view
Details of the available Callback types
case failed(GamificationError)
Informs the client that the template actions are faliled with an error and provides the error information
case rewardLoose
Informs the client that the template actions are performed and the user loose the reward
case rewardWon
Informs the client that the template actions are performed and the user won the reward
var message: String
Detailed message for particular callback type
Details of the available Event types
case mediaPause
Informs that the audio/video is paused or stopped
case mediaPlay
Informs that the audio/video is started or about to start playing
case sdkClose
Informs that the sdk is close
case sdkOpen
Informs that the sdk is open
var message: String
Detailed message for particluar event type
Details of all available error types
case errorHandled
Informs the cleint that the error is occured and it is already handled by sdk
case invalidKey
Informs the the authentication key provided is not correct
case invalidUser
Informs the the user key provided is not correct or expired
case noTemplate
Informs the client that the template requested is not supported or the template is not available to user at that moment
case notDefined(String)
Provides the undefined use cases with the error description
case notInitialized
Informs the the intialization is failed by any other scenarios
case unAuthorisedClient
Informs that the client is an unauthorised either the identifier of app is not matched or not registered. Please check with OnMobile to know the identifier or to add the app identifier in sdk
case unknown
Unhandled cases
var message: String
Detailed message for particluar error type
MIT
OnMobile Global Limited
Naresh Babu Kommana
link |
Stars: 0 |
Last commit: 2 weeks ago |
UI Revamp
Swiftpack is being maintained by Petr Pavlik | @ptrpavlik | @swiftpackco | API | Analytics