In-Game Messaging

 


Interstitial Message Optimization in SDK 3.0

  • Predefined Message Location at game start event

    To simplify the integration of Interstitial Message, we added a predefined message location at the game start where we found is a popular usage scenario. With the predefined setting, you can use Interstitial Message for game start event without additional development effort.

  • Customizable Layout

    Allow more customizable layout to match with Game’s look and feel.

Show Interstitial Message

To show Interstitial Message that with the Location ID specified.

Call showInterstitialNotification method to show Interstitial message, and its parameters are:

  • Location ID(Trigger Point id) . a string needed to be setup in KTplay portal.

  • Notification event callback . callback to handle Interstitial display status and can pass null if no handling is needed.

//Create event listener OnInterstialNotificationEventListener 

OnInterstialNotificationEventListener listener = new OnInterstialNotificationEventListener() 
{
    @Override
    public void onInterstialNotificationEvent(
    String identifier,
    KTInterstialNotificationEvent event) {

    }
};

KTPlay.showInterstitialNotification(tp_id,listener); //tp_id is the Trigger Point id

//callback
KTInterstitialNotificationBlock interstitialNotificationBlock =  ^(NSString *identifier,KTInterstitialNotificationEvent notificationEvent){
     if([identifier isEqualToString:tp_id]){   //tp_id is the Trigger 
        switch(notificationEvent){
            case  KTInterstitialNotificationWillAppear: // soon appear
             // game pause
             break;
             case  KTInterstitialNotificationDidCancel:  // cancelled 
             // game resume
             break;
              case  KTInterstitialNotificationDidFinish: // shown
             // game resume
             break;
        }
     }
 };

//show interstitial notification
 [KTPlay showInterstitialNotification:tp_id       notificationBlock:interstitialNotificationBlock];

//KTInterstitialNotificationCallback monitor interstitial Notification status change

static void interstitialNotificationCallback(const char *identifier,KTInterstitialNotificationEventC notificationEvent){
   if(strcmp(identifier,tp_id)){
    switch(notificationEvent){
      case  KTInterstitialNotificationWillAppearC: // soon appear
       // game pause
       break;
       case  KTInterstitialNotificationDidCancelC:  // canclled
       // game resume
       break;
        case  KTInterstitialNotificationDidFinishC: //  shown
       // game resume
       break;
    }
   }
}
KTPlayC::showInterstitialNotification("gameover",interstitialNotificationCallback);

KTPlay.ShowInterstitialNotification ("gameover", (string interstitialID, KTPlay.KTInterstialNotificationEvent interstialNotificationEvent) => {
            switch(interstialNotificationEvent){
            case  KTPlay.KTInterstialNotificationEvent.InterstitialNotificationWillAppear: // soon appear
                // game pause
                break;
            case  KTPlay.KTInterstialNotificationEvent.InterstitialNotificationDidCancel:  // canclled
                // game resume
                break;
            case  KTPlay.KTInterstialNotificationEvent.InterstitialNotificationDidFinish: //  shown
                // game resume
                break;
            }
        });

Preload Interstitial Message

Preload message will improve message display response time, and there are 2 methods involved in preloading.

  • requestInterstitialNotification method is used to request KTplay backend to load Interstitial Message with the location ID specified.

  • hasInterstitialNotification method is used to check if Interstitial Message is existed (loaded).

if (!KTPlay.hasInterstitialNotification(tp_id)) //tp_id is the Trigger Point id
{
     KTPlay.requestInterstitialNotification(tp_id);
}

if (![KTPlay hasInterstitialNotification:@tp_id])
{
    [KTPlay requestInterstitialNotification:@tp_id];
}

if (!KTPlayC::hasInterstitialNotification(tp_id))
{
    KTPlayC::requestInterstitialNotification(tp_id);
}

if (!KTPlay.HasInterstitialNotification(tp_id))
{
    KTPlay.RequestInterstitialNotification(tp_id);
}

Disable Notification

The method will disable or stop receiving In-Game Message, so Message will not be displayed.

Disable Notification will be needed during Game initialization, as message displayed will affect user experience. The Notification will be enabled again after game initialization.

setNotificationEnabled can be used to enable and disable notification

    
   //onCreate 
    KTPlay.setNotificationEnabled(false);
    KTplay.startWithAppKey(context,"app key","app secret");
    
    //... Game initializing...

  //On Game Initialization Finished
    KTPlay.setNotificationEnabled(true);//enable notification
}

-(BOOL)application:(UIApplication*)application didFinishLaunchingWithOptions:(NSDictionary*)launchOptions
{

[KTPlay setNotificationEnabled:NO];

[KTPlay startWithAppKey:@"2na1elK" 
appSecret:@"3e8bbe12d983b8d1cdc174f49d7a8448613af078"];
//...
    return YES;
}

//... Game initializing...

//On Game Initialization Finished
[KTPlay setNotificationEnabled:YES];

//Disable notification can be called based on Game need, however, during game initialization, the disable notification needed to be called before Ktplay SDK initialization, as to avoid notification received before initialisation completed.
KTPlayC::setNotificationEnabled(false);

//enable notification
KTPlayC::setNotificationEnabled(true);

//Disable notification can be called based on Game need, however, during game initialization, the disable notification needed to be called before Ktplay SDK initialization, as to avoid notification received before initialisation completed.
KTPlay.SetNotificationEnabled(false);

//enable notification
KTPlay.SetNotificationEnabled(true);

Handle Deeplink

Deeplinking is a mechanism to communicate change of designation of execution, Deeklink can be embedded in both Banner or Interstitial Message to direct player to predefined location or a Deeplink ID. DeepLink ID identifying the execution location that is configured in KTplay portal, and will be send to game client via in-Game Message, once Game received will direct the player to the location needed.

KTPlay.setOnDeepLinkListener(new OnDeepLinkListener() {
            @Override
            public void onDeepLink(String deepLink) {
                Log.i(TAG, "KTPlay Dispatch deeplinks");
                Game.processDeepLink(deepLink);
            }
        });

  [KTPlay setDeepLinkBlock:^(NSString *linkSchemas) {
            NSLog(@"\n\n  deeplink :   %@  \n\n",linkSchemas); 
           if ([linkSchemas isEqualToString:@"GoToLeaderboard"]) {
                 // Game receive the predefined link defintion ("GoToLeaderboard"), and go to leaderboard UI
            }
  }];

void deepLinkCallback (const char *linkSchemas){
    Game::processDeepLink(linkSchemas)
    // Game receive the predefined link defintion ("GoToLeaderboard"), and go to leaderboard UI
}

KTPlayC::setDeepLinkCallback(deepLinkCallback );

KTPlay.SetDeepLinkDelegate ((string linkScheme) => {
      Game.processDeepLink(linkScheme);
    //Game receive the predefined link defintion ("GoToLeaderboard"), and go to leaderboard UI
});
Have more questions? Submit a request

0 Comments

Please sign in to leave a comment.