-
Notifications
You must be signed in to change notification settings - Fork 84
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[final][hold] subscriber attributes (#121)
* added skeleton methods to index.ts * added methods to RNPurchases * added sample attributes to the app example * added android method calls * updated versions of purchases-android and purchases-hybrid-common * updated call to setAttributes to separate conversion of hashMap * bump version numbers and purchases-hybrid-common version * updated purchases-hybrid-common version, added hybrid additions file to xcode project * bumped sdk version * bump xcode * fix xcode version * updated simulator * PR comments * added test mocks and test for invalidate purchaser info cache * added test cases to index.test.js * Adds script to download android common files * updates android common files Co-authored-by: Cesar de la Vega <[email protected]>
- Loading branch information
Showing
15 changed files
with
369 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -645,6 +645,87 @@ describe("Purchases", () => { | |
expect(NativeModules.RNPurchases.purchaseProduct).toBeCalledTimes(0); | ||
}); | ||
|
||
|
||
describe("invalidate purchaser info cache", () => { | ||
describe("when invalidatePurchaserInfoCache is called", () => { | ||
it("makes the right call to Purchases", () => { | ||
const Purchases = require("../index").default; | ||
Purchases.invalidatePurchaserInfoCache(); | ||
|
||
expect(NativeModules.RNPurchases.invalidatePurchaserInfoCache).toBeCalledTimes(1); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("setAttributes", () => { | ||
describe("when setAttributes is called", () => { | ||
it("makes the right call to Purchases", () => { | ||
const Purchases = require("../index").default; | ||
const attributes = { band: "AirBourne", song: "Back in the game" } | ||
Purchases.setAttributes(attributes); | ||
|
||
expect(NativeModules.RNPurchases.setAttributes).toBeCalledTimes(1); | ||
expect(NativeModules.RNPurchases.setAttributes).toBeCalledWith(attributes); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("setEmail", () => { | ||
describe("when setEmail is called", () => { | ||
it("makes the right call to Purchases", () => { | ||
const Purchases = require("../index").default; | ||
const email = "[email protected]"; | ||
|
||
Purchases.setEmail(email); | ||
|
||
expect(NativeModules.RNPurchases.setEmail).toBeCalledTimes(1); | ||
expect(NativeModules.RNPurchases.setEmail).toBeCalledWith(email); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("setPhoneNumber", () => { | ||
describe("when setPhoneNumber is called", () => { | ||
it("makes the right call to Purchases", () => { | ||
const Purchases = require("../index").default; | ||
const phoneNumber = "+123456789"; | ||
|
||
Purchases.setPhoneNumber(phoneNumber); | ||
|
||
expect(NativeModules.RNPurchases.setPhoneNumber).toBeCalledTimes(1); | ||
expect(NativeModules.RNPurchases.setPhoneNumber).toBeCalledWith(phoneNumber); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("setDisplayName", () => { | ||
describe("when setDisplayName is called", () => { | ||
it("makes the right call to Purchases", () => { | ||
const Purchases = require("../index").default; | ||
const displayName = "Garfield"; | ||
|
||
Purchases.setDisplayName(displayName); | ||
|
||
expect(NativeModules.RNPurchases.setDisplayName).toBeCalledTimes(1); | ||
expect(NativeModules.RNPurchases.setDisplayName).toBeCalledWith(displayName); | ||
}); | ||
}); | ||
}); | ||
|
||
describe("setPushToken", () => { | ||
describe("when setPushToken is called", () => { | ||
it("makes the right call to Purchases", () => { | ||
const Purchases = require("../index").default; | ||
const pushToken = "65a1ds56adsgh6954asd"; | ||
|
||
Purchases.setPushToken(pushToken); | ||
|
||
expect(NativeModules.RNPurchases.setPushToken).toBeCalledTimes(1); | ||
expect(NativeModules.RNPurchases.setPushToken).toBeCalledWith(pushToken); | ||
}); | ||
}); | ||
}); | ||
|
||
const mockPlatform = OS => { | ||
jest.resetModules(); | ||
jest.doMock("Platform", () => ({OS, select: objs => objs[OS]})); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
1.0.10 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -57,6 +57,10 @@ export default class App extends React.Component { | |
loading: false | ||
}); | ||
} | ||
Purchases.setPhoneNumber("123456789"); | ||
Purchases.setDisplayName("Garfield"); | ||
Purchases.setAttributes({ "favorite_cat": "garfield" }); | ||
Purchases.setEmail("[email protected]"); | ||
} catch (e) { | ||
// eslint-disable-next-line no-console | ||
console.log(`Error ${JSON.stringify(e)}`); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#!/bin/sh | ||
|
||
cd ../android/ | ||
|
||
VERSION=$1 | ||
CURRENT_VERSION=$(cat .common_version) | ||
|
||
if [ "$VERSION" == "$CURRENT_VERSION" ]; then | ||
echo "The newest version is already installed. Exiting." | ||
exit 0 | ||
fi | ||
|
||
pwd | ||
|
||
URL=https://github.com/RevenueCat/purchases-hybrid-common/archive/$VERSION.zip | ||
|
||
echo "Downloading Purchases common hybrid SDKs classes $VERSION from $URL, this may take a minute." | ||
|
||
if ! which curl > /dev/null; then echo "curl command not found. Please install curl"; exit 1; fi; | ||
if ! which unzip > /dev/null; then echo "unzip command not found. Please install unzip"; exit 1; fi; | ||
|
||
if [[ -d ../android/src/main/java/com/revenuecat/purchases/common ]]; then | ||
echo "Old Android classes found. Removing them and installing version $VERSION" | ||
rm -rf ../android/src/main/java/com/revenuecat/purchases/common | ||
fi | ||
|
||
curl -sSL $URL > tempCommon.zip | ||
# In some cases the temp folder can not be created by unzip, https://github.com/RevenueCat/react-native-purchases/issues/26 | ||
mkdir -p tempCommon | ||
unzip -o tempCommon.zip -d tempCommon | ||
ls tempCommon | ||
mv tempCommon/purchases-hybrid-common-$VERSION/android/common/src/main/java/com/revenuecat/purchases/common/ ../android/src/main/java/com/revenuecat/purchases/ | ||
rm -r tempCommon | ||
rm tempCommon.zip | ||
|
||
if ! [[ -d ../android/src/main/java/com/revenuecat/purchases/common ]]; then | ||
echo "Common files not found. Please reinstall react-native-purchases"; exit 1; | ||
fi | ||
|
||
echo "$VERSION" > .common_version |
Oops, something went wrong.