Skip to content
This repository was archived by the owner on Oct 20, 2020. It is now read-only.

Commit b49ba7a

Browse files
committed
added more readme, further installation instructions
1 parent b90185f commit b49ba7a

1 file changed

Lines changed: 19 additions & 2 deletions

File tree

README.md

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ InAppBilling.open()
2020
1. `npm install --save react-native-billing`
2121
2. `rnpm link react-native-billing`
2222

23-
With this, [rnpm](https://github.com/rnpm/rnpm) will do most of the heavy lifting for linking, **but** you will still need add your Google Play license key to the `strings.xml` (step 5).
23+
With this, [rnpm](https://github.com/rnpm/rnpm) will do most of the heavy lifting for linking. **But**, you will still need add your Google Play license key to the `strings.xml` (step 5). If you are using a React Native version less than v18.0 you will also have to do step 4.3 (override `onActivityResult`).
2424

2525
## Manual installation Android
2626

@@ -43,7 +43,18 @@ With this, [rnpm](https://github.com/rnpm/rnpm) will do most of the heavy liftin
4343
}
4444
```
4545

46-
4. Register package in `MainActivity.java`
46+
4. Edit `MainActivity.java`. Step 4.3 is only required if you are using a lower React Native version than 18.0 and/or your `MainActivity` class does not inherit from `ReactActivity`.
47+
1. Add `import com.idehub.Billing.InAppBillingBridgePackage`
48+
2. Register package in ReactInstanceManager: `.addPackage(new InAppBillingBridgePackage(this))`
49+
3. Override `onActivityResult`:
50+
```java
51+
@Override
52+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
53+
mReactInstanceManager.onActivityResult(requestCode, resultCode, data);
54+
}
55+
```
56+
57+
Larger example:
4758

4859
```java
4960
// Step 1; import package:
@@ -69,7 +80,13 @@ With this, [rnpm](https://github.com/rnpm/rnpm) will do most of the heavy liftin
6980

7081
...
7182
}
83+
84+
@Override
85+
protected void onActivityResult(int requestCode, int resultCode, Intent data) {
86+
mReactInstanceManager.onActivityResult(requestCode, resultCode, data);
87+
}
7288
...
89+
// Step 3:
7390
```
7491
5. Add your Google Play license key as a line to your `android/app/src/main/res/values/strings.xml` with the name `RNB_GOOGLE_PLAY_LICENSE_KEY`. For example:
7592
```xml

0 commit comments

Comments
 (0)