Skip to main content
Version: 4.x.x

Web Store

Configure​

To use 101XP Web Store please add the next key to your AndroidManifest.xml:

AndroidManifest.xml
<meta-data
android:name="com.platform101xp.sdk.web_store_project_name"
android:value="@string/web_store_project_name" />

Please, ask your release manager for parameter web_store_project_name.

Usage​

To show 101XP Web Store please use the method:

// Java
void showWebStore(Map<String, String> properties);
//OR
void showWebStore(Map<String, String> properties, List<String> allowedLocale);

// Kotlin
fun showWebStore(properties: Map<String, String>?, allowedLocale: List<String>? = null)

properties - additional optional properties appending to the final 101XP Web Store url as "key=value"

allowedLocale - allowed locale for run Web Store, if current device locale not find in "allowedLocale" just use first element "allowedLocale".

Example​

// Java
// Add your properties
Map<String, String> properties = new HashMap<String, String>();
properties.put("first_purchase_property", your_purchase_property);

// Show 101XP Web Store
Platform101XP.showWebStore(properties)

// OR any call with allowed locale
Platform101XP.showWebStore(properties, Arrays.asList("en","ru"));

// Kotlin
val properties: MutableMap<String, String> = HashMap()
properties["first_purchase_property"] = "first_property"

Platform101XP.showWebStore(properties)
//OR
Platform101XP.showWebStore(properties,Arrays.asList("ru"))

if current device locale not find in your Arrays just use first element.

Handling an authorization error in onShowWebStoreResult() or onCheckMobilePurchase()​

To properly work the web store, you have to call the authorization in the case of an authorization error like on the code snippet below:

// Java
@Override
public void onShowWebStoreResult(Platform101XPError error) {
if (error != null) {
// Handle an error
if (error.getErrorType() == Platform101XPError.ErrorType.ERROR_NOT_AUTHORIZED)
Platform101XP.authorize();
} else {
// Web Store shown successfully
}
}

@Override
public void onCheckMobilePurchase(String itemName, boolean bought, Platform101XPError error) {
if (error != null) {
// Handle an error
if (error.getErrorType() == Platform101XPError.ErrorType.ERROR_NOT_AUTHORIZED)
Platform101XP.authorize();
} else {
// Web Store result check bought param
}
}

// Kotlin
override fun onShowWebStoreResult(error: Platform101XPError?) {
error?.let {
if (error.getErrorType() === BaseErrorType.ERROR_NOT_AUTHORIZED)
Platform101XP.authorize()
else
showMessage("$error")
}
}

override fun onCheckMobilePurchase(itemName: String?, bought: Boolean, error: Platform101XPError?) {
error?.let {
showMessage("Error onCheckMobilePurchase: $error")
} ?: run {
Log.d(Platform101XP.LOG_TAG,"onCheckMobilePurchase itemName:$itemName bought:${if (bought) "true" else "false"}")
}
}

Check purchase in Web Store​

To check purchase in Web Store for user use method:

// Java
Platform101XP.checkMobilePurchase(String itemName);

// Kotlin
Platform101XP.checkMobilePurchase(itemName: String);

The result of checkMobilePurchase() is sent to the method of listener.

// Java
void onCheckMobilePurchase(String itemName, boolean bought, Platform101XPError error) {
}

// Kotlin
override fun onCheckMobilePurchase(itemName: String?, bought: Boolean, error: Platform101XPError?) {
}