TOP > Basic Guide
Table of Contents
- Region Setting
- Authentication
- Initialize SDK
- Getting User Information
- Mission Achievement
- SDK Portal
- Ad Portal
For Japan
RakutenReward.shared.region = RakutenRewardRegion.japan
There are 3 types of login. According to your environment, please select proper one.
Login Option | Description | Support |
---|---|---|
rakutenAuth | This is default option, provide login by SDK, SDK handled all login and user identifier | Japan |
rid | Rakuten ID SDK with RID, Login covers by ID SDK, and use API token for SDK | Japan |
rae | Rakuten ID SDK with RAE, Login covers by ID SDK, and use token for SDK | Japan |
By default, login option is rakutenAuth
RakutenReward.shared.tokenType = TokenType.rakutenAuth
To use SDK API, developers need to set token type after login
RakutenReward.shared.tokenType = TokenType.rid
and pass (API-C) token value in startSession API. Access token value will be set automatically when startSessionAPI returns success
RakutenReward.shared.startSession(appCode: "Your App Key", accessToken: <Access token>, completion: { r in
if case .success(let user) =r { // use portal or use additional setup
}
}
From version 3.3.1, developers require to call logout API whenever user log out to properly clear token and data
Refer to Log Out
To use SDK API, developers need to set token type after login
RakutenReward.shared.tokenType = TokenType.rae
and pass access API token value in startSession API. Access token value will be set automatically when startSessionAPI returns success
RakutenReward.shared.startSession(appCode: "Your App Key", accessToken: <Access token>, completion: { r in
if case .success(let user) =r { // use portal or use additional setup
}
}
From version 3.3.1, developers require to call logout API whenever user log out to properly clear token and data
Refer to Log Out
This is for external login options, If you use Rakuten Login SDK, you don't need to use this option.
RakutenReward.shared.openLoginPage({result in
switch result:
case .dismissByUser: // resume in another time
case .LogInCompleted: // starting session
case .failToShowLoginPage: // presenting problem
})
Logging user out:
RakutenReward.shared.logout { }
To use Reward SDK, need to establish SDK session first (to collect SDK user's basic information)
Call startSession method with parameters
From version 6.1.0
RakutenReward.shared.startSession(appCode: "Your App Key", accessToken: <Access token>, tokenType: <token type>, completion: { r in
if case .success(let user) =r { // use portal or use additional setup
}
}
Before version 6.1.0
RakutenReward.shared.startSession(appCode: "Your App Key", accessToken: <Access token>, completion: { r in
if case .success(let user) =r { // use portal or use additional setup
}
}
Parameter name | Description |
---|---|
appCode | Application Key (This is from Rakuten Reward Developer Portal) |
token | Access token to access Reward SDK API-C API |
tokenType | Either rid or rae (version 6.1.0 and above only) |
- Check if user has logged in to Reward SDK,
- if not open log in page
- Start session after log in
if RakutenReward.shared.isLogin() {
RakutenReward.shared.startSession(appCode: <#appcode#>, completion:<#callback#>)
} else {
RakutenReward.shared.openLoginPage({_ in
// starting session ...
})
}
RakutenReward.shared.user?.getName()
RakutenReward.shared.user?.currentPointRank()
To achieve mission, developers need to call post action API.
After achieving the mission, notification will be shown.
RakutenReward.shared.logAction(actionCode: "<actionCode>", completionHandler: { actionResult in })
actionCode is provided by Reward SDK Developer Portal.
The user achieved the mission, notification UI is shown.
Reward SDK provides Modal and Banner UI
There are 4 types of Mission Achievement UI. Modal, Banner, and No UI, and Custom which developed by developers.
You can decide type by Developer Portal
Notification Type | UI |
---|---|
Modal | Show Modal UI provided by SDK |
Banner | Show Banner UI provided by SDK |
Custom | Developer can create UI by themselves |
Small Ad Banner / Banner_50 | Show Banner_50 UI provided by SDK |
Big Ad Banner / Banner_250 | Show Banner_250 UI provided by SDK |
No UI | Not show any UI |
We provide User Portal UI for developers. In SDK Portal, developers can see user status (mission, unclaim list, current point, point history etc...)
Call Open SDK Portal API:
RakutenReward.shared.openPortal(completionHandler: { result in
// Handle success or fail to open portal
})
Below are the portal UIs:
*Ad Portal APIs are available from version 3.1.0 (JP region only)
Call Open Ad Portal API:
RakutenReward.shared.openAdPortal { completion in
// Handle success or fail to open ad portal
}
Below are the ad portal UIs:
LANGUAGE :