Skip to content

Commit

Permalink
Fixed AndroidManifest.xml issue with the newer Unity versions.
Browse files Browse the repository at this point in the history
  • Loading branch information
hojjatjafary committed Oct 12, 2019
1 parent b3ad8b2 commit 2341206
Show file tree
Hide file tree
Showing 2 changed files with 149 additions and 146 deletions.
215 changes: 109 additions & 106 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,106 +1,109 @@

# CafebazaarUnity
Cafebazaar In-app purchase Unity plugin


## BUILD INSTRUCTION
To build `BazaarIAB.jar` from the java source code:
1. Open a command prompt
2. Navigate to JavaPlugin folder
3. Type `gradlew createJar`
4. After the build is succeeded you can find `BazaarIAB.jar` in the build folder


## INSIDE UNITY PROJECT
This plugin has not any prefab to use, it will manage the required objects.

The `BazaarIAB` is the interface that let you call billing functions, all methods are static so is it not required to instantiate this class. Before calling any other function try to initialize the plugin by calling the `init` with the public key provided by Cafebazaar developer portal.

This call will check to see if billing is supported and fire the `billingSupportedEvent` if it is. If billing is not supported the `billingNotSupportedEvent` will fire and you should not call any other methods.

There is `IABEventManager` class that you can subscribe to all plugin events.

After you find out that the billing is supported, you can call `queryInventory` by providing all of your available skus. When the `queryInventorySucceededEvent` fires it will contain a list of all the current purchases, subscriptions and a list of all your project sku details. You can use this information to setup your store. The list is also handy when you want to consume a purchase. Any `BazaarPurchases` returned are available for consumption.

Add the plugin activity in the Application section of the `AndroidManifest.xml`:

<meta-data android:name="billing.service" android:value="bazaar.BazaarIabService" />
<activity android:name="com.bazaar.BazaarIABProxyActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />

Also add the required permissions to your manifest:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR" />

# Methods
Methods are inside `BazaarIAB` class.
``` csharp
// Initializes the billing system
public static void init(string publicKey)

// Get current version of plugin
public static string GetVersion()

// Toggles high detail logging on/off
public static void enableLogging(bool shouldEnable)

// Unbinds and shuts down the billing service
public static void unbindService()

// Returns whether subscriptions are supported on the current device
public static bool areSubscriptionsSupported()

// Sends a request to get all completed purchases and product information as setup in the Bazaar dashboard about the provided skus (requires user to be logged in otherwise you will get error)
public static void queryInventory(string[] skus)

// Sends a request to get all product information as setup in the CafeBazaar portal about the provided skus (do not required user to be loggedin)
public static void querySkuDetails(string[] skus)

// Sends a request to get all completed purchases (requires user to be logged in otherwise you will get error)
public static void queryPurchases()

// Sends out a request to purchase the product
public static void purchaseProduct(string sku)
public static void purchaseProduct(string sku, string developerPayload)

// Sends out a request to consume the product
public static void consumeProduct(string sku)
// Sends out a request to consume all of the provided products
public static void consumeProducts(string[] skus)
```

# Events
You can access events from `IABEventManager` class.
```csharp

// Fired after init is called when billing is supported on the device
public static event Action billingSupportedEvent;
// Fired after init is called when billing is not supported on the device
public static event Action<string> billingNotSupportedEvent;

// Fired when the inventory and purchase history query has returned
public static event Action<List<BazaarPurchase>,List<BazaarSkuInfo>> queryInventorySucceededEvent;
// Fired when the inventory and purchase history query fails
public static event Action<string> queryInventoryFailedEvent;

// Fired when the SkuDetails query has returned
public static event Action<List<BazaarSkuInfo>> querySkuDetailsSucceededEvent;
// Fired when the SkuDetails query fails
public static event Action<string> querySkuDetailsFailedEvent;

// Fired when the purchase history query has returned
public static event Action<List<BazaarPurchase>> queryPurchasesSucceededEvent;
// Fired when the purchase history query fails
public static event Action<string> queryPurchasesFailedEvent;

// Fired when a purchase succeeds
public static event Action<BazaarPurchase> purchaseSucceededEvent;
// Fired when a purchase fails
public static event Action<string> purchaseFailedEvent;

// Fired when a call to consume a product succeeds
public static event Action<BazaarPurchase> consumePurchaseSucceededEvent;
// Fired when a call to consume a product fails
public static event Action<string> consumePurchaseFailedEvent;

```

# CafebazaarUnity
Cafebazaar In-app purchase Unity plugin


## BUILD INSTRUCTION
To build `BazaarIAB.jar` from the java source code:
1. Open a command prompt
2. Navigate to JavaPlugin folder
3. Type `gradlew createJar`
4. After the build is succeeded you can find `BazaarIAB.jar` in the build folder


## INSIDE UNITY PROJECT
This plugin has not any prefab to use, it will manage the required objects.

The `BazaarIAB` is the interface that let you call billing functions, all methods are static so is it not required to instantiate this class. Before calling any other function try to initialize the plugin by calling the `init` with the public key provided by Cafebazaar developer portal.

This call will check to see if billing is supported and fire the `billingSupportedEvent` if it is. If billing is not supported the `billingNotSupportedEvent` will fire and you should not call any other methods.

There is `IABEventManager` class that you can subscribe to all plugin events.

After you find out that the billing is supported, you can call `queryInventory` by providing all of your available skus. When the `queryInventorySucceededEvent` fires it will contain a list of all the current purchases, subscriptions and a list of all your project sku details. You can use this information to setup your store. The list is also handy when you want to consume a purchase. Any `BazaarPurchases` returned are available for consumption.

Add the plugin activity in the Application section of the `AndroidManifest.xml`:

<meta-data android:name="billing.service" android:value="bazaar.BazaarIabService" />
<activity android:name="com.bazaar.BazaarIABProxyActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />

Also add the required permissions to your manifest:

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR" />

# Methods
Methods are inside `BazaarIAB` class.
``` csharp
// Initializes the billing system
public static void init(string publicKey)

// Get current version of plugin
public static string GetVersion()

// Toggles high detail logging on/off
public static void enableLogging(bool shouldEnable)

// Unbinds and shuts down the billing service
public static void unbindService()

// Returns whether subscriptions are supported on the current device
public static bool areSubscriptionsSupported()

// Sends a request to get all completed purchases and product information as setup in the Bazaar dashboard about the provided skus (requires user to be logged in otherwise you will get error)
public static void queryInventory(string[] skus)

// Sends a request to get all product information as setup in the CafeBazaar portal about the provided skus (do not required user to be loggedin)
public static void querySkuDetails(string[] skus)

// Sends a request to get all completed purchases (requires user to be logged in otherwise you will get error)
public static void queryPurchases()

// Sends out a request to purchase the product
public static void purchaseProduct(string sku)
public static void purchaseProduct(string sku, string developerPayload)

// Sends out a request to consume the product
public static void consumeProduct(string sku)
// Sends out a request to consume all of the provided products
public static void consumeProducts(string[] skus)
```

# Events
You can access events from `IABEventManager` class.
```csharp

// Fired after init is called when billing is supported on the device
public static event Action billingSupportedEvent;
// Fired after init is called when billing is not supported on the device
public static event Action<string> billingNotSupportedEvent;

// Fired when the inventory and purchase history query has returned
public static event Action<List<BazaarPurchase>,List<BazaarSkuInfo>> queryInventorySucceededEvent;
// Fired when the inventory and purchase history query fails
public static event Action<string> queryInventoryFailedEvent;

// Fired when the SkuDetails query has returned
public static event Action<List<BazaarSkuInfo>> querySkuDetailsSucceededEvent;
// Fired when the SkuDetails query fails
public static event Action<string> querySkuDetailsFailedEvent;

// Fired when the purchase history query has returned
public static event Action<List<BazaarPurchase>> queryPurchasesSucceededEvent;
// Fired when the purchase history query fails
public static event Action<string> queryPurchasesFailedEvent;

// Fired when a purchase succeeds
public static event Action<BazaarPurchase> purchaseSucceededEvent;
// Fired when a purchase fails
public static event Action<string> purchaseFailedEvent;

// Fired when a call to consume a product succeeds
public static event Action<BazaarPurchase> consumePurchaseSucceededEvent;
// Fired when a call to consume a product fails
public static event Action<string> consumePurchaseFailedEvent;

```

# Thanks
- [mohsen-srn](https://github.com/mohsen-srn) for pointing out the AndroidManifest.xml issue in newer Unity versions.
80 changes: 40 additions & 40 deletions UnityProject/Assets/Plugins/Android/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fanafzar.bazaarIABTest"
android:installLocation="preferExternal"
android:theme="@android:style/Theme.NoTitleBar"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"/>

<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
</activity>

<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="billing.service" android:value="bazaar.BazaarIabService" />
<activity android:name="com.bazaar.BazaarIABProxyActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />

</application>

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

</manifest>
<?xml version="1.0" encoding="utf-8"?>
<manifest
xmlns:android="http://schemas.android.com/apk/res/android"
package="com.fanafzar.bazaarIABTest"
android:installLocation="preferExternal"
android:theme="@android:style/Theme.NoTitleBar"
android:versionCode="1"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"
android:anyDensity="true"/>

<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
</activity>

<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
<meta-data android:name="billing.service" android:value="bazaar.BazaarIabService" />
<activity android:name="com.bazaar.BazaarIABProxyActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />

</application>

<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />

<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

</manifest>

0 comments on commit 2341206

Please sign in to comment.