JMRSDK Development
v4.45
v4.45
  • Jio Mixed Reality SDK Documentation
    • Changelog 4.45
      • Upgrade Guide 4.45
    • Application Requirements
  • Device Information
    • JioGlass
    • JioDive
  • Supported Smartphones
  • Controller Specifications
    • Physical Controllers
    • External Gamepad
    • Virtual Controller / Virtual Keyboard for JioGlass
  • Getting Started
    • Development Platform
    • Setting Up Jio Mixed Reality Project in Unity
    • URP Support
      • Setting Up Your Project With URP
      • Reverting Back to Built-In Render Pipeline
  • JMRSDK
    • JMRSDK Content
    • JMRMixedReality Prefab
    • System Dock
    • JMRRig
      • Local Rig
      • Setting Homepage (Quit functionality)
      • Recenter Application on Resume
  • Develop
    • Editor Emulator
    • JioGlass Controller Interactions
    • Cameras
    • Tesseract Mixed Reality UI Toolkits
    • In-app purchase
    • Examples
    • Video Tutorials
  • Interaction
    • Gaze Interaction
      • Gaze and Click
      • Gaze and Dwell
    • Interaction
      • Pointer Manager
        • Examples
      • Active Input Source
    • Interfaces
      • IFocusable
      • ISelectHandler
      • ISelectClickHandler
      • IBackHandler
      • IHomeHandler
      • IMenuHandler
      • IFn1Handler
      • IFn2Handler
      • ITouchHandler
      • ISwipeHandler
      • IVoiceHandler
      • IManipulationHandler
    • Controller Input Actions
      • Touchpad - Touch
      • Touchpad - Swipe
      • Source Buttons
      • Manipulation
    • Actions
    • Device State
      • JioDive Device State
      • JioGlass Device State
      • Controller Device State
  • Voice
    • Voice
      • Speech Events
      • Speech Result
      • Speech Error
      • Speech Session End
      • Speech Cancel
    • Listening
  • Tracking
    • Tracking
      • Coordinate System
    • Tracking Framework
      • TrackerManager Actions
        • Get Head Position
        • Get Head Rotation
        • Get Head Transform
      • TrackerManager Methods
        • Get Head Position
        • Get Head Rotation
        • Get Head Transform
    • Recenter
  • Building and Testing
    • Building to Target Device
      • Merging AndroidManifest
      • Performance Optimization
      • App optimization
    • Running your application
      • JioImmerse App For Jio Mixed Reality (JMR) Devices
      • Running the application on Prism (Holoboard)
    • IPD Calibration
  • Publish
    • Branding Guidelines
    • Licensing Journey In Android JioImmerse
    • Signing your App
    • Publishing to Google Play Store
      • Play Store Upload Journey
    • Publishing to JioImmerse Developer Console
    • Publishing to Apple Store
    • Licensing Journey in iOS JioImmerse
    • iOS Deep linking
  • Capturing and Recording
    • Capture Videos and Screenshots
      • Capturing Screenshot/Videos using scrcpy
      • Capturing Screenshot/Videos using Vysor
  • Troubleshooting
    • FAQs - Develop
    • FAQs - Building to device
      • Gradle
      • FAQs - iOS
    • FAQs - Running and Publishing
    • Laser Point Not Visible
Powered by GitBook
On this page
  • In-app purchases in JMR applications
  • Integrating IAP
  • 1. Modify android manifest:
  • 2. Creating an IAP Store:
  • 3. Handling intents to open the IAP store of your application:
  • 4. Adding an open JioImmerse button:
  1. Develop

In-app purchase

PreviousTesseract Mixed Reality UI ToolkitsNextExamples

Last updated 11 months ago

In-app purchases (IAP) are now a pivotal feature in our apps, providing a great way to enhance user experience and generate revenue. With IAP, consumers can buy additional content, features, or services directly within the app, making their experience more engaging and personalized. This feature helps developers offer more value to users while creating new income streams through one-time purchases, subscriptions, or consumables. Integrating IAP allows apps to stay competitive, innovative, and financially sustainable.

In-app purchases in JMR applications

Integrating IAP

To integrate IAP into your application, follow these steps.

1. Modify android manifest:

Apps made with JMRSDK are shown in the JioImmerse app drawer, where the application launches in MR mode. Native popups cannot be displayed on split-screen. To show native popups we must show the application in mono screen mode from Android Launcher. Modify the Android manifest to show the application in the Android launcher.

Add this intent in Android Manifest file along with the intent-filter for MR-LAUNCHER

<intent-filter>
        <action android:name="android.intent.action.MAIN" />
        <category android:name="android.intent.category.LAUNCHER" />
</intent-filter>

2. Creating an IAP Store:

To create an IAP store, make a scene in your project.

  • The IAP store scene should be in portrait orientation

  • Do NOT configure this scene for JioMixedReality

  • Camera - Setup a Camera from GameObject > Camera. Tag this camera as MainCamera.

  • In the IAP store scene, add a Button that says - Open JioImmerse. This button shall trigger the functionality as shown in point 4 below.

3. Handling intents to open the IAP store of your application:

  • Once, the application is opened/resumed from the Android launcher, it should quickly switch to the Shop scene in portrait orientation.

  • If the application is minimized while in the IAP store, we quit the application, this keeps the application ready to be opened from either of the launchers. However, we do NOTquit when a transaction is in progress to prevent purchases from failing.

Here is a sample script that does the same, attach this to the first scene of your application.

  • Modify the shopSceneIndex to the index of the shop scene as present in build settings.

  • Change isPurchasing to true while any purchase is in progress.

using System;
using System.Linq;
using UnityEngine;
using UnityEngine.SceneManagement;

public class SceneStartManager: MonoBehaviour
{
    private static SceneStartManager instance;
    public int shopSceneIndex = 5;    //Modify this
    public bool isPurchasing = false; //Modify this when purchase is in progress
    
    private void Awake()
    {
        if (instance == null)
        {
            instance = this;
            DontDestroyOnLoad(gameObject);
            CheckIntentAndLoadScene();
        }
        else Destroy(gameObject);
    }

    private void OnApplicationPause(bool pauseStatus)
    {
        if (!pauseStatus) CheckIntentAndLoadScene();
        else if (SceneManager.GetActiveScene().buildIndex == shopSceneIndex && !isPurchasing) Application.Quit();
    }

    private string[] categoryArray = Array.Empty<string>();
    private void CheckIntentAndLoadScene()
    {
        AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
        AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");

        AndroidJavaObject intent = currentActivity.Call<AndroidJavaObject>("getIntent");
        AndroidJavaObject categories = intent.Call<AndroidJavaObject>("getCategories");

        categoryArray = categories != null ? categories.Call<string[]>("toArray", new object[] {Array.Empty<string>()}) : Array.Empty<string>();

        if (categoryArray.Contains("android.intent.category.LAUNCHER")) LoadScene(shopSceneIndex);
    }
    private void LoadScene(int sceneIndex)
    {
        if (SceneManager.GetActiveScene().buildIndex != sceneIndex) 
        {
            SceneManager.LoadScene(sceneIndex);
            Screen.orientation = ScreenOrientation.Portrait;
        }
    }
}

4. Adding an open JioImmerse button:

Make sure to add a button called Open JioImmerse at the bottom of the screen and invoke this functionality when pressed.

public void OpenJioImmerse()
{
#if UNITY_ANDROID && !UNITY_EDITOR
	AndroidJavaClass unityPlayer = new AndroidJavaClass("com.unity3d.player.UnityPlayer");
	AndroidJavaObject currentActivity = unityPlayer.GetStatic<AndroidJavaObject>("currentActivity");
	AndroidJavaObject packageManager = currentActivity.Call<AndroidJavaObject>("getPackageManager");
	AndroidJavaObject intent = packageManager.Call<AndroidJavaObject>("getLaunchIntentForPackage", "com.jiotesseract.mr.jxr");

	if (intent != null) currentActivity.Call("startActivity", intent);
	else
	{
		Application.OpenURL("https://play.google.com/store/apps/details?id=com.jiotesseract.mr.jxr");
		Debug.Log("App not installed");
	}
#endif
}

In this scene, utilize package provided by Unity to implement in-app purchases in your application through Google Play Billing. Get creative in how you want to showcase in-app purchases to attract the most consumers.

com.unity.purchasing
Android Manifest after modification
Sample shop screen