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
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.
In this scene, utilize com.unity.purchasing 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.
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.