Hive User Engagement (UE) provides deep link function with coupons, which allows to invite game users to a specific location or event page in games with a simple tap of the link, or to get rewards directly.

In Hive, the action you want to perform through scheme URL is called user engagement action. When game performs the action specified in the given URL, Hive requests to the game in the form of a user engagement event.

What is User Engagement?

UE is a service which performs requests from inside and outside of the application, and performs the following functions:

  • Perform scheme URL from outside of the app through deep link or push notification.
  • Perform scheme URL from inside of the app through interwork.
  • With Hive SDK v4.4.0 and later,
    • Send the access history to game app via external route such as QR codes and links created by User Acquisition to request rewards.
    • Send the access history to game app via offerwall or other functions of Hive to request rewards. (Request for CPI rewards)
    • Ensure that Game Client implement setEngagementReady API and send the request when Hive module is available to perform the function of UE to process CPI rewards and others.


How to Indicate Scheme URL on Hive

Scheme URL is a format to express the action of UE. It indicates what action is defined in the Scheme URL and who it is applied to. Hive-using Scheme URL follows a standard format so-called Uniform Resource Identifier (URI), and composes of service field and common field.

  • Standard format: {scheme}://{host}/{path}?{query}
  • Hive format: {scheme}://{host}/{api}?{parameters}

Service field: {scheme}://{host} | Common field: /{api}?{parameters}

Hive format indicates an event that processes on Hive SDK and includes the given {api} as shown in the Common Field section. For this reason, the common field of the Hive format composes of /{api}?{parameters} in place of /{path}?{query} of a standard format. For a list of {api} that includes on Hive format, see Common Field.

Using Scheme URL in Games

In addition to using UE for coupon deep linking purposes, if you need to move to a specific location in games (e.g., dungeon, gift box, shop, etc.) for your promotional purposes, ensure to define the path in the game, and provide Scheme URL. This Scheme URL is converted to a landing URL on Hive Console, and then delivered to the user.
For more information about the scheme URL in games, see If the host of Scheme URL is game.

Service Field

Service field of Scheme URL is {scheme}://{host}, which indicates the path that the deep link is delivered to the Hive SDK and composes of scheme and host.

scheme

There are three paths where URLs are passed to the app:

Push

Whether or not the game app targeted by the Scheme URL is running, the URL recipient will receive a push message that contains the Scheme URL. When the receiver taps the message, Push Scheme URL is sent to Hive Client, and then Hive Client processes the URL.

    • e.g., push://{host}/{path}?{query}

Deep Link

If user taps a URL via external means such as text messages, and web browser, and if the scheme field of this URL is filled with the AppID of a specific game on the user device, the game is executed and the URL is delivered to Hive SDK. In case the game app is not installed, it move to installation page.

    • e.g., com.com2us.example://{host}/{path}?{query}

The user follows is different depending on the status of game installation when using deep link scheme.

  1. If the game is installed
    When tapping the deep link, the user checks game tips first, and moves to the game.
  2. If the game is not installed
    When user taps the link in a message, it notifies the rewards are available after game installation. Since the game is not installed, it will be moved to Download Market (Google Play Store / Apple App Store).

Interwork

If a user touch the specific link URL of the Promotion screen (Banner, Notice, etc.) of the Hive SDK while the app is running, and the scheme field of that URL is “interwork“, the URL is delivered to Hive SDK.

    • e.g., interwork://{host}/{path}?{query}

You can call the request for processing interwork scheme by using processURI API to send URL from game to Hive SDK directly.

Unity®

C++

Android

iOS

 

Host

Host specifies who is responsible for the action requested:

    • game: Action which the game is responsible for
    • hive: Action which Hive SDK is responsible for

Common Field

Common field of Scheme URL is /{api}/{parameters}, which indicates the action to process including required information:
api clarifies what action to take through the URL. The following actions can be taken depending on the host:

If the host of Scheme URL is hive

Be aware that available API is different depending on authentication version, v4 or v1.

API Implementation Auth v4 Auth v1
authlogin
auth/login
Hive membership login (Guest -> Verified account) X O
socialinquiry
social/inquiry
Access to Hive 1:1 inquiry page O O
promotionshow
promotion/show
Promotion custom view exposure O O
promotioncoupon
promotion/coupon
Processed the promotion coupon as used O O
offerwallshow
promotion/offerwall
Offerwall exposure O O
iappromote Item purchase reservation (Hive SDK v4.5.0 and later with Hive IAP v4) O O
iappurchase Item purchase on spot banner (Hive SDK v4.5.0 and later with Hive IAP v4)
When implementing iappurchase, setEngagementReady() becomes false automatically. After purchase, you need to set setEngagementReady() as true
O O
social/myinquiry Access to Hive My Inquiry page O O
social/profile Access to profile page O O

Hive receives notifications before and after the process relevant to UE through EngagementListener. The game may require work such as pausing the game as needed.

For more about iappromote and iappurchase, see the contents below.

iappromote

Hive IAP v4 with Hive SDK v4.5.0 and later supports this feature. It provides purchase reservation for users before executing a game. The feature functions the same with Promotional IAP provided by iOS 11, and supports android-base environment. iappromote is available on event pages, push services and messages.

  • When user clicks scheme URL via event pages, push services and messages, gain the purchase data by executing the game.
  • Call the iappromote scheme and receive EngagementEventType.IAP_PROMOTE as a result data. With the result value, implement checkPromotePurchase API to gain the market PID. You can continue the purchase process when implementing purchase API with the market PID you get as a reference.
  • iappromote is available for both on iOS and Android.
  • Structure of the scheme URL: [AppID/push/interwork]://hive/iappromote?marketpid=[marketpid]
  • e.g.,
    • interwork://hive/iappromote?marketpid=com.com2us.hivesdk.normal.freefull.apple.global.ios.universal.cs02
    • Replace the part in red to the market PID related to the reserved purchase.

iappurchase

Hive IAP v4 with Hive SDK v4.5.0 and later supports this feature. You can sell items on the spot banner by using the iappurchase in the scheme URL.

  • If you call the iappurchase shceme, purchase logic is implemented. So, make sure to initialize the market and gain the store information prior to executing the scheme. This means, implement marketConnect API and getProductInfo API before changing the state of setEngagementReady as true.
  • As game executes the logic after purchase, it pauses engagement action (setEngagementReady becomes false automatically).
  • After purchase is complete, change the state of setEngagementReady as true to continue the action.
  • Structure of the scheme URL: [AppID/push/interwork]://hive/iappurchase?marketpid=[marketpid]
  • e.g.,
    • interwork://hive/iappurchase?marketpid=com.com2us.hivesdk.normal.freefull.apple.global.ios.universal.cs01
    • Replace the part in red to the market PID related to the reserved purchase.

Sync iappurchase with Spot Banner

If you want to sell items by using iappurchase scheme, utilize Spot Banner. View the guideline to use Spot Banner

  • Set a spot banner ID at a desired location or timing in the game to encourage users to purchase items.
  • Call the spot banner ID. When user taps the spot banner, implement interwork scheme. The registered EngagementListener will send the running state of interwork.
  • If you call the interwork shceme, purchase logic is implemented. So, make sure to initialize the market and gain the store information prior to executing the scheme. This means, implement marketConnect API and getProductInfo API before calling the spot banner.
  • As game executes the logic after purchase, it pauses engagement action (setEngagementReady becomes false automatically).
  • After purchase is complete, change the state of setEngagementReady as true to continue the action.
  • Enter the spot banner ID on Hive Console > Promotion > Campaign Settings > Spot Banner, and insert the scheme URL in the internal link. Request how to register a spot banner to Business PM.
  • e.g.,
    • interwork://hive/iappurchase?marketpid=com.com2us.hivesdk.normal.freefull.apple.global.ios.universal.cs01
    • Replace the part in red to the market PID related to the reserved purchase.
  • When you register the banner on the console, test the purchase in your game.

 

If the host of Scheme URL is game

In this case, the game must perform the requested action. Hive SDK is handling Scheme URL, and then send the result as JSONObject format through EngagementListener. The results are divided into the scheme, api, and param key. Make sure that game performs the relevant action in appropriate time after receiving the values.

  • e.g., Giving items in postbox
    • URL Scheme : com.com2us.example://game/postboxadditem?item_id=123456&item_title=item01
    • JSONObject result from Hive SDK

For more details about how to implement UE, see Sample Code of Implementing User Engagement > Declaring and Registering Global Callback.

Project Settings

To use UE in the game app, set by OS before building the app.

Android Settings

Set the launchMode method as singleTask or singleTop. The method is one of Main Activity items in AndroidManifest.xml file.

iOS Settings

  1. Select the Build of an app you want to develop on the list of Xcode TARGETS.
  2. Select the Info tab.
  3. Add Additional url type properties items in URL Types section to input AppID in Bundle Identifier and URL Schemes field.

Implementing User Engagement

Declaring and Registering Global Callback

Declare and register global callback to apply Hive UE. How to declaration and registration depends on the version of Hive SDK.

Hive SDK v4.5.0 and later

You must register global callback using the handler registration API of Promotion class. Followings are sample codes.

Unity®

API Reference: hive.Promotion.setEngagementListener

C++

API Reference: Promotion::setEngagementHandler

Kotlin

API Reference: setEngagementListener

Java

API Reference: com.hive.Promotion.setEngagementListener

Swift

API Reference: setEngagementHandler(_:)

Objective-C

API Reference: HIVEPromotion setEngagementHandler

Settings to Handle User Engagement Event

The Hive SDK is generally able to process incoming requests if the Hive login is complete. However, in case of the first execution, etc., even after the login, compensation payment etc. may not be possible if it is before the game server DB creation. Therefore, you need to inform Hive SDK about whether UE event handling is possible from the game..

  • The default settings for event handling is false.
  • If event handling is set as true, existing queued events are processed immediately, and subsequent events are processed immediately.
  • If event handling is set as false, incoming events are queued until the setting is converts to true.
  • Setting it to true should be called after the login , and Setting it to false has no restriction on the time of the call.
  • (With Hive SDK v4.4.0 and later) All games using Hive SDK are required to implement this API to give CPI rewards.
  • If a user enters the app through the invitation links or QR codes generated by User Acquisition, or through offerwall pages, the entry history transfer and reward payment request are performed depending on the changed state by calling this API.
  • You must call the API at the point when the game can perform the function of the UE.

Use setEngagementReady() method in the Promotion class to set whether UE event is available to process or not. Followings are sample codes to set as true.

Unity®

API Reference: hive.Promotion.setEngagementReady

C++

API Reference: Promotion::setEngagementReady

Kotlin

API Reference: Promotion.setEngagementReady

Java

API Reference: com.hive.Promotion.setEngagementReady

Swift

API Reference: PromotionInterface .setEngagementReady

Objective-C

API Reference: HIVEPromotion:setEngagementReady

Result Code for Request to Redeem Coupon

If promo code errors or other problems exist while processing coupon event, UE module displays a popup in accordance with error code that Hive defines to notify the circumstances to users.

The host value of coupon scheme URL is always hive.

Code Description Code Description
200 Access to wrong parameter 305 Unique coupon expired the available count
201 Sent wrong hash value 306 Expired coupon
202 Exceeded the usage limit for the account 307 Lack of required data to distinguish new/existing user or Active User system error
203 The available count of coupon exceeded 308 Not the target of this event. For existing users only
204 Mismatched with AppID and issued coupon 309 Not the target of this event. For new users only
300 Coupon with wrong digit code 310 New/Existing event without registration in games
301 No coupon data in the promotion received 400 Failed to send all items
302 Failed to search the coupon code 401 Failed to send several items
303 Coupon in use 500 DB error
304 Used coupon 501 Communication failure