Posted on

Native UI – Cross Platform Native Plugins: Essential Kit

Download

Documentation: https://assetstore.essentialkit.voxelbusters.com/

0:00 Welcome to Native UI CPNP2
0:22 Overview
0:56 Setup
1:09 Usage

Native UIs can be used to show special messages in your game with native Android or iOS windows.

IG_NativeUI.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VoxelBusters.EssentialKit;
using System;

public class IG_NativeUI : MonoBehaviour
{
    public static IG_NativeUI instance;

    public DateTime currentDateTime; //IG_NativeUI.instance.currentDateTime;
   
    // Start is called before the first frame update
    void Start()
    {
        instance = this;
    }

    //IG_NativeUI.instance.ShowAlertDialog("Are you sure?", "Would you like to proceed with this action?");
    public void ShowAlertDialog(string title, string message)
    {
        AlertDialog dialog = AlertDialog.CreateInstance();
        dialog.Title = title;
        dialog.Message = message;
        dialog.AddButton("Yes", () =>
        {
            Debug.Log("Yes button clicked");
        });
        dialog.AddCancelButton("No", () =>
        {
            Debug.Log("Cancel button clicked");
        });
        dialog.Show(); //Show the dialog
    }

    //IG_NativeUI.instance.ShowDatePicker();
    public void ShowDatePicker()
    { 
        DatePicker datePicker = DatePicker.CreateInstance(DatePickerMode.Date);
        datePicker.SetOnValueChange((date) =>
        {
            Debug.Log("Date Time change : " + date);
            currentDateTime = (DateTime)date;
        });
        datePicker.SetOnCloseCallback((result) =>
        {
            Debug.Log("Dismissed the picker with selected date : " + result.SelectedDate);
            currentDateTime = (DateTime)result.SelectedDate;
        });
        datePicker.Show();
    }

   
}
Posted on

Notifications – Cross Platform Native Plugins: Essential Kit

Download

Documentation: https://assetstore.essentialkit.voxelbusters.com/

0:00 Welcome to Notifications CPNP2
0:20 Overview
1:27 Setup
2:45 iOS
3:05 Android
4:29 Usage

For this lesson on how to use the Cross Platform Native Plugins 2 in Unity, I will show you how to use the Notification services. Notifications are important to have in your game as they will help in boosting audience retention. Notification can be used to remind your players to come back and keep playing.

IG_Notifications.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VoxelBusters.EssentialKit;

public class IG_Notifications : MonoBehaviour
{
    public static IG_Notifications instance;

    NotificationSettings settings;

    bool isRegistered;

    // Start is called before the first frame update
    void Start()
    {
        instance = this;

        VoxelBusters.EssentialKit.NotificationServices.GetSettings((result) =>
        {
            settings = result.Settings;
            // update console
            Debug.Log(settings.ToString());

            Debug.Log("Permission status : " + settings.PermissionStatus);
        });

        if(!settings.PushNotificationEnabled)
        {
            VoxelBusters.EssentialKit.NotificationServices.UnregisterForPushNotifications();
            isRegistered = false;
        }
         
    }

    //IG_Notifications.instance.CreateLocalNotification("GoldMindFull", "Your gold minds are full!", 3600, false);
   public void CreateLocalNotification(string notificationID, string notificationTitle, double time, bool canRepeat)
    {
        if(settings.PermissionStatus == NotificationPermissionStatus.NotDetermined)
        {
            VoxelBusters.EssentialKit.NotificationServices.RequestPermission(NotificationPermissionOptions.Alert | NotificationPermissionOptions.Sound | NotificationPermissionOptions.Badge, callback: (result, error) =>
            {
                Debug.Log("Request for access finished.");
                Debug.Log("Notification access status: " + result.PermissionStatus);
            });
        }
        if(settings.PermissionStatus == NotificationPermissionStatus.Denied)
        {
            Utilities.OpenApplicationSettings();
        }
        if (settings.PermissionStatus == NotificationPermissionStatus.Authorized)
        {


            INotification notification = NotificationBuilder.CreateNotification(notificationID)
        .SetTitle(notificationTitle)
        .SetTimeIntervalNotificationTrigger(time, repeats: canRepeat)
        .Create();

            VoxelBusters.EssentialKit.NotificationServices.ScheduleNotification(notification, (error) =>
            {
                if (error == null)
                {
                    Debug.Log("Request to schedule notification finished successfully.");
                }
                else
                {
                    Debug.Log("Request to schedule notification failed with error. Error: " + error);
                }
            });
        }
    }


    private void OnEnable()
    {
        VoxelBusters.EssentialKit.NotificationServices.RegisterForPushNotifications((result, error) =>
        {   
            if (error == null)
            {   
                Debug.Log("Remote notification registration finished successfully. Device token: " + result.DeviceToken);
            }   
            else
            {
                Debug.Log("Remote notification registration failed with error. Error: " + error.Description);
            }
        });
        isRegistered = VoxelBusters.EssentialKit.NotificationServices.IsRegisteredForPushNotifications();
    }

    private void OnDisable()
    {
        if(isRegistered)
            VoxelBusters.EssentialKit.NotificationServices.UnregisterForPushNotifications();
    }
}
Posted on

Rate My App – Cross Platform Native Plugins: Essential Kit

Download

Documentation: https://assetstore.essentialkit.voxelbusters.com/

0:00 Welcome to Rate My App CPNP2
0:22 Overview
1:19 Setup
1:53 Usage and Code

The Rate My App service gives you the ability to ask your audience to review and rate your game. Getting reviews from your users will allow you to receive feedback from those that play your game. This will also help with boosting your game on the app stores.

IG_RateMyApp.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using VoxelBusters.EssentialKit;

public class IG_RateMyApp : MonoBehaviour
{
    public static void DisplayRateApp()
    {
        RateMyApp.AskForReviewNow();
    } 
}