Skip to content

Commit 2341206

Browse files
committed
Fixed AndroidManifest.xml issue with the newer Unity versions.
1 parent b3ad8b2 commit 2341206

File tree

2 files changed

+149
-146
lines changed

2 files changed

+149
-146
lines changed

README.md

Lines changed: 109 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +1,109 @@
1-
2-
# CafebazaarUnity
3-
Cafebazaar In-app purchase Unity plugin
4-
5-
6-
## BUILD INSTRUCTION
7-
To build `BazaarIAB.jar` from the java source code:
8-
1. Open a command prompt
9-
2. Navigate to JavaPlugin folder
10-
3. Type `gradlew createJar`
11-
4. After the build is succeeded you can find `BazaarIAB.jar` in the build folder
12-
13-
14-
## INSIDE UNITY PROJECT
15-
This plugin has not any prefab to use, it will manage the required objects.
16-
17-
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.
18-
19-
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.
20-
21-
There is `IABEventManager` class that you can subscribe to all plugin events.
22-
23-
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.
24-
25-
Add the plugin activity in the Application section of the `AndroidManifest.xml`:
26-
27-
<meta-data android:name="billing.service" android:value="bazaar.BazaarIabService" />
28-
<activity android:name="com.bazaar.BazaarIABProxyActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
29-
30-
Also add the required permissions to your manifest:
31-
32-
<uses-permission android:name="android.permission.INTERNET" />
33-
<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR" />
34-
35-
# Methods
36-
Methods are inside `BazaarIAB` class.
37-
``` csharp
38-
// Initializes the billing system
39-
public static void init(string publicKey)
40-
41-
// Get current version of plugin
42-
public static string GetVersion()
43-
44-
// Toggles high detail logging on/off
45-
public static void enableLogging(bool shouldEnable)
46-
47-
// Unbinds and shuts down the billing service
48-
public static void unbindService()
49-
50-
// Returns whether subscriptions are supported on the current device
51-
public static bool areSubscriptionsSupported()
52-
53-
// 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)
54-
public static void queryInventory(string[] skus)
55-
56-
// 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)
57-
public static void querySkuDetails(string[] skus)
58-
59-
// Sends a request to get all completed purchases (requires user to be logged in otherwise you will get error)
60-
public static void queryPurchases()
61-
62-
// Sends out a request to purchase the product
63-
public static void purchaseProduct(string sku)
64-
public static void purchaseProduct(string sku, string developerPayload)
65-
66-
// Sends out a request to consume the product
67-
public static void consumeProduct(string sku)
68-
// Sends out a request to consume all of the provided products
69-
public static void consumeProducts(string[] skus)
70-
```
71-
72-
# Events
73-
You can access events from `IABEventManager` class.
74-
```csharp
75-
76-
// Fired after init is called when billing is supported on the device
77-
public static event Action billingSupportedEvent;
78-
// Fired after init is called when billing is not supported on the device
79-
public static event Action<string> billingNotSupportedEvent;
80-
81-
// Fired when the inventory and purchase history query has returned
82-
public static event Action<List<BazaarPurchase>,List<BazaarSkuInfo>> queryInventorySucceededEvent;
83-
// Fired when the inventory and purchase history query fails
84-
public static event Action<string> queryInventoryFailedEvent;
85-
86-
// Fired when the SkuDetails query has returned
87-
public static event Action<List<BazaarSkuInfo>> querySkuDetailsSucceededEvent;
88-
// Fired when the SkuDetails query fails
89-
public static event Action<string> querySkuDetailsFailedEvent;
90-
91-
// Fired when the purchase history query has returned
92-
public static event Action<List<BazaarPurchase>> queryPurchasesSucceededEvent;
93-
// Fired when the purchase history query fails
94-
public static event Action<string> queryPurchasesFailedEvent;
95-
96-
// Fired when a purchase succeeds
97-
public static event Action<BazaarPurchase> purchaseSucceededEvent;
98-
// Fired when a purchase fails
99-
public static event Action<string> purchaseFailedEvent;
100-
101-
// Fired when a call to consume a product succeeds
102-
public static event Action<BazaarPurchase> consumePurchaseSucceededEvent;
103-
// Fired when a call to consume a product fails
104-
public static event Action<string> consumePurchaseFailedEvent;
105-
106-
```
1+
2+
# CafebazaarUnity
3+
Cafebazaar In-app purchase Unity plugin
4+
5+
6+
## BUILD INSTRUCTION
7+
To build `BazaarIAB.jar` from the java source code:
8+
1. Open a command prompt
9+
2. Navigate to JavaPlugin folder
10+
3. Type `gradlew createJar`
11+
4. After the build is succeeded you can find `BazaarIAB.jar` in the build folder
12+
13+
14+
## INSIDE UNITY PROJECT
15+
This plugin has not any prefab to use, it will manage the required objects.
16+
17+
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.
18+
19+
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.
20+
21+
There is `IABEventManager` class that you can subscribe to all plugin events.
22+
23+
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.
24+
25+
Add the plugin activity in the Application section of the `AndroidManifest.xml`:
26+
27+
<meta-data android:name="billing.service" android:value="bazaar.BazaarIabService" />
28+
<activity android:name="com.bazaar.BazaarIABProxyActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
29+
30+
Also add the required permissions to your manifest:
31+
32+
<uses-permission android:name="android.permission.INTERNET" />
33+
<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR" />
34+
35+
# Methods
36+
Methods are inside `BazaarIAB` class.
37+
``` csharp
38+
// Initializes the billing system
39+
public static void init(string publicKey)
40+
41+
// Get current version of plugin
42+
public static string GetVersion()
43+
44+
// Toggles high detail logging on/off
45+
public static void enableLogging(bool shouldEnable)
46+
47+
// Unbinds and shuts down the billing service
48+
public static void unbindService()
49+
50+
// Returns whether subscriptions are supported on the current device
51+
public static bool areSubscriptionsSupported()
52+
53+
// 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)
54+
public static void queryInventory(string[] skus)
55+
56+
// 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)
57+
public static void querySkuDetails(string[] skus)
58+
59+
// Sends a request to get all completed purchases (requires user to be logged in otherwise you will get error)
60+
public static void queryPurchases()
61+
62+
// Sends out a request to purchase the product
63+
public static void purchaseProduct(string sku)
64+
public static void purchaseProduct(string sku, string developerPayload)
65+
66+
// Sends out a request to consume the product
67+
public static void consumeProduct(string sku)
68+
// Sends out a request to consume all of the provided products
69+
public static void consumeProducts(string[] skus)
70+
```
71+
72+
# Events
73+
You can access events from `IABEventManager` class.
74+
```csharp
75+
76+
// Fired after init is called when billing is supported on the device
77+
public static event Action billingSupportedEvent;
78+
// Fired after init is called when billing is not supported on the device
79+
public static event Action<string> billingNotSupportedEvent;
80+
81+
// Fired when the inventory and purchase history query has returned
82+
public static event Action<List<BazaarPurchase>,List<BazaarSkuInfo>> queryInventorySucceededEvent;
83+
// Fired when the inventory and purchase history query fails
84+
public static event Action<string> queryInventoryFailedEvent;
85+
86+
// Fired when the SkuDetails query has returned
87+
public static event Action<List<BazaarSkuInfo>> querySkuDetailsSucceededEvent;
88+
// Fired when the SkuDetails query fails
89+
public static event Action<string> querySkuDetailsFailedEvent;
90+
91+
// Fired when the purchase history query has returned
92+
public static event Action<List<BazaarPurchase>> queryPurchasesSucceededEvent;
93+
// Fired when the purchase history query fails
94+
public static event Action<string> queryPurchasesFailedEvent;
95+
96+
// Fired when a purchase succeeds
97+
public static event Action<BazaarPurchase> purchaseSucceededEvent;
98+
// Fired when a purchase fails
99+
public static event Action<string> purchaseFailedEvent;
100+
101+
// Fired when a call to consume a product succeeds
102+
public static event Action<BazaarPurchase> consumePurchaseSucceededEvent;
103+
// Fired when a call to consume a product fails
104+
public static event Action<string> consumePurchaseFailedEvent;
105+
106+
```
107+
108+
# Thanks
109+
- [mohsen-srn](https://github.com/mohsen-srn) for pointing out the AndroidManifest.xml issue in newer Unity versions.
Lines changed: 40 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
1-
<?xml version="1.0" encoding="utf-8"?>
2-
<manifest
3-
xmlns:android="http://schemas.android.com/apk/res/android"
4-
package="com.fanafzar.bazaarIABTest"
5-
android:installLocation="preferExternal"
6-
android:theme="@android:style/Theme.NoTitleBar"
7-
android:versionCode="1"
8-
android:versionName="1.0">
9-
<supports-screens
10-
android:smallScreens="true"
11-
android:normalScreens="true"
12-
android:largeScreens="true"
13-
android:xlargeScreens="true"
14-
android:anyDensity="true"/>
15-
16-
<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
17-
<activity android:name="com.unity3d.player.UnityPlayerNativeActivity" android:label="@string/app_name">
18-
<intent-filter>
19-
<action android:name="android.intent.action.MAIN" />
20-
<category android:name="android.intent.category.LAUNCHER" />
21-
</intent-filter>
22-
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
23-
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
24-
</activity>
25-
26-
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
27-
<meta-data android:name="billing.service" android:value="bazaar.BazaarIabService" />
28-
<activity android:name="com.bazaar.BazaarIABProxyActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
29-
30-
</application>
31-
32-
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />
33-
34-
<uses-permission android:name="android.permission.INTERNET" />
35-
<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR" />
36-
<uses-permission android:name="android.permission.WAKE_LOCK" />
37-
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
38-
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
39-
40-
</manifest>
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<manifest
3+
xmlns:android="http://schemas.android.com/apk/res/android"
4+
package="com.fanafzar.bazaarIABTest"
5+
android:installLocation="preferExternal"
6+
android:theme="@android:style/Theme.NoTitleBar"
7+
android:versionCode="1"
8+
android:versionName="1.0">
9+
<supports-screens
10+
android:smallScreens="true"
11+
android:normalScreens="true"
12+
android:largeScreens="true"
13+
android:xlargeScreens="true"
14+
android:anyDensity="true"/>
15+
16+
<application android:icon="@drawable/app_icon" android:label="@string/app_name" android:debuggable="true">
17+
<activity android:name="com.unity3d.player.UnityPlayerActivity" android:label="@string/app_name">
18+
<intent-filter>
19+
<action android:name="android.intent.action.MAIN" />
20+
<category android:name="android.intent.category.LAUNCHER" />
21+
</intent-filter>
22+
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
23+
<meta-data android:name="unityplayer.ForwardNativeEventsToDalvik" android:value="false" />
24+
</activity>
25+
26+
<meta-data android:name="unityplayer.UnityActivity" android:value="true" />
27+
<meta-data android:name="billing.service" android:value="bazaar.BazaarIabService" />
28+
<activity android:name="com.bazaar.BazaarIABProxyActivity" android:theme="@android:style/Theme.Translucent.NoTitleBar.Fullscreen" />
29+
30+
</application>
31+
32+
<uses-sdk android:minSdkVersion="10" android:targetSdkVersion="21" />
33+
34+
<uses-permission android:name="android.permission.INTERNET" />
35+
<uses-permission android:name="com.farsitel.bazaar.permission.PAY_THROUGH_BAZAAR" />
36+
<uses-permission android:name="android.permission.WAKE_LOCK" />
37+
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
38+
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
39+
40+
</manifest>

0 commit comments

Comments
 (0)