Skip to content

Latest commit

 

History

History
253 lines (190 loc) · 6.19 KB

README.md

File metadata and controls

253 lines (190 loc) · 6.19 KB

TOP > Basic Guide

Table of Contents

Region Setting

For Japan

RakutenReward.shared.region = RakutenRewardRegion.japan



Authentication

Login Options

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

Switch Login Option

By default, login option is rakutenAuth

RakutenAuth

RakutenReward.shared.tokenType = TokenType.rakutenAuth

RID

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

RAE

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

Log In

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
  }) 

Login

Log out

Logging user out:

RakutenReward.shared.logout { }

Initialize SDK

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)

Initialization flow with Built-in Login service

  1. Check if user has logged in to Reward SDK,
  2. if not open log in page
  3. Start session after log in
if RakutenReward.shared.isLogin() {
  RakutenReward.shared.startSession(appCode: <#appcode#>, completion:<#callback#>) 
} else {
  RakutenReward.shared.openLoginPage({_ in 
    // starting session ...
  }) 
}

Getting user information

Get user's full name

RakutenReward.shared.user?.getName()

Get user Current point and rank:

RakutenReward.shared.user?.currentPointRank()

Mission Achievement

To achieve mission, developers need to call post action API.
After achieving the mission, notification will be shown.

Post Action

RakutenReward.shared.logAction(actionCode: "<actionCode>", completionHandler: { actionResult in })

actionCode is provided by Reward SDK Developer Portal.

Notification UI

The user achieved the mission, notification UI is shown.
Reward SDK provides Modal and Banner UI

Modal Banner

Notification Type

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

SDK Portal

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:

Portal1

Portal2

Portal3

Portal4

Portal5

Portal6

Ad Portal (Deprecated from version 5.x)

*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:

AdPortal1


LANGUAGE :

ja