Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.2.0 #320

Merged
merged 3 commits into from
Jul 8, 2024
Merged

3.2.0 #320

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
node_modules/
.eslintrc
*.d.ts
52 changes: 52 additions & 0 deletions .github/workflows/CI.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,58 @@ jobs:
contents: write
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: "16"

- name: 'Checkout ${{ inputs.ref }}'
uses: actions/checkout@v3
with:
path: source
ref: '${{ inputs.ref }}'

- name: Install dependencies
run: yarn --frozen-lockfile --prefer-offline
working-directory: source/

- name: Linter
run: |
npx eslint . --ext .js,.jsx,.ts,.tsx
working-directory: source/
tsc:
name: Generate Declaration Files
permissions:
actions: write
contents: write
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: "16"

- name: 'Checkout ${{ inputs.ref }}'
uses: actions/checkout@v3
with:
path: source
ref: '${{ inputs.ref }}'

- name: Install dependencies
run: yarn --frozen-lockfile --prefer-offline
working-directory: source/

- name: Generate .d files
run: |
npx tsc
working-directory: source/
eslintapps:
name: ESLint Sample Apps
permissions:
actions: write
contents: write
id-token: write
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ class NamiBridgeModule(reactContext: ReactApplicationContext) :
} else {
Arguments.createArray()
}
val settingsList = mutableListOf("extendedClientInfo:react-native:3.2.0-beta.01")
val settingsList = mutableListOf("extendedClientInfo:react-native:3.2.0")
namiCommandsReact?.toArrayList()?.filterIsInstance<String>()?.let { commandsFromReact ->
settingsList.addAll(commandsFromReact)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,15 @@ class NamiPaywallManagerBridgeModule(reactContext: ReactApplicationContext) :
}

@ReactMethod
fun setProductDetails(productDetails: String, allowOffers: Boolean) {
fun setProductDetails(productDetails: String, allowOffers: Boolean) {
NamiPaywallManager.setProductDetails(productDetails, allowOffers = false)
}

@ReactMethod
fun setAppSuppliedVideoDetails(url: String, name: String?) {
// To be implemented
}

@ReactMethod
fun addListener(eventName: String?) {
}
Expand Down
2 changes: 1 addition & 1 deletion examples/TestNamiTV/nami_amazon_product_details.json
Original file line number Diff line number Diff line change
Expand Up @@ -98,4 +98,4 @@
"currency": "USD"
}
]
}
}
3 changes: 2 additions & 1 deletion ios/NamiPaywallManagerBridge.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,9 @@ @interface RCT_EXTERN_MODULE(RNNamiPaywallManager, NSObject)

RCT_EXTERN_METHOD(buySkuCancel)

RCT_EXTERN_METHOD(setProductDetails:(NSString *)productDetails allowOffers:(BOOL *))
RCT_EXTERN_METHOD(setProductDetails:(NSString *)productDetails allowOffers:(nullable BOOL *))

RCT_EXTERN_METHOD(setAppSuppliedVideoDetails:(NSString *)url name:(nullable NSString *))

+ (BOOL)requiresMainQueueSetup {
return YES;
Expand Down
7 changes: 6 additions & 1 deletion ios/NamiPaywallManagerBridge.swift
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,12 @@ class RNNamiPaywallManager: RCTEventEmitter {
}

@objc(setProductDetails:allowOffers:)
func setProductDetails(productDetails: String, allowOffers: Bool) {
func setProductDetails(productDetails _: String, allowOffers _: Bool) {
// Do nothing on Apple
}

@objc(setAppSuppliedVideoDetails:allowOffers:)
func setAppSuppliedVideoDetails(url _: String, name _: String?) {
// To be implemented
}
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-nami-sdk",
"version": "3.2.0-beta.1",
"version": "3.2.0",
"description": "React Native Module for Nami - Easy subscriptions & in-app purchases, with powerful built-in paywalls and A/B testing.",
"main": "index.ts",
"types": "index.d.ts",
Expand Down
2 changes: 1 addition & 1 deletion react-native-nami-sdk.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Pod::Spec.new do |s|
s.source_files = "ios/**/*.{h,m,swift}"
s.requires_arc = true

s.dependency 'Nami', '3.2.0-beta.01'
s.dependency 'Nami', '3.2.0'
s.dependency 'React'

end
4 changes: 2 additions & 2 deletions src/NamiCampaignManager.d.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { NativeEventEmitter, EmitterSubscription } from 'react-native';
import { LaunchCampaignError, NamiCampaign, NamiPaywallAction, NamiPurchase, PaywallLaunchContext } from './types';
import { LaunchCampaignError, NamiCampaign, NamiPaywallActionHandler, PaywallLaunchContext } from './types';
export declare const RNNamiCampaignManager: any;
export declare enum NamiCampaignManagerEvents {
ResultCampaign = "ResultCampaign",
Expand All @@ -10,7 +10,7 @@ interface ICampaignManager {
emitter: NativeEventEmitter;
allCampaigns: () => Promise<Array<NamiCampaign>>;
isCampaignAvailable(campaignSource: string | null): Promise<boolean>;
launch: (label?: string, withUrl?: string, context?: PaywallLaunchContext, resultCallback?: (success: boolean, error?: LaunchCampaignError) => void, actionCallback?: (action: NamiPaywallAction, campaignId: string, paywallId: string, campaignName?: string, campaignType?: string, campaignLabel?: string, campaignUrl?: string, paywallName?: string, segmentId?: string, externalSegmentId?: string, deeplinkUrl?: string, skuId?: string, componentChangeId?: string, componentChangeName?: string, purchaseError?: string, purchases?: NamiPurchase[]) => void) => void;
launch: (label?: string, withUrl?: string, context?: PaywallLaunchContext, resultCallback?: (success: boolean, error?: LaunchCampaignError) => void, actionCallback?: NamiPaywallActionHandler) => void;
refresh: () => void;
registerAvailableCampaignsHandler: (callback: (availableCampaigns: NamiCampaign[]) => void) => EmitterSubscription['remove'];
}
Expand Down
10 changes: 5 additions & 5 deletions src/NamiCampaignManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,21 +67,21 @@ export const NamiCampaignManager: ICampaignManager = {
componentChange: body.componentChange,
segmentId: body.segmentId,
externalSegmentId: body.externalSegmentId,
deeplinkUrl: body.deeplinkUrl,
deeplinkUrl: body.deeplinkUrl,
sku: body.sku,
purchaseError: body.purchaseError,
purchases: body.purchases,
}
actionCallback(paywallEvent)
};
actionCallback(paywallEvent);
}
},
);
RNNamiCampaignManager.launch(
label ?? null,
withUrl ?? null,
context ?? null,
resultCallback ?? (() => { }),
actionCallback ?? (() => { }),
resultCallback ?? (() => {}),
actionCallback ?? (() => {}),
);
},

Expand Down
1 change: 1 addition & 0 deletions src/NamiPaywallManager.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,5 +28,6 @@ export interface INamiPaywallManager {
isHidden: () => Promise<boolean>;
isPaywallOpen: () => Promise<boolean>;
setProductDetails: (productDetails: string, allowOffers: boolean) => void;
setAppSuppliedVideoDetails: (url: string, name?: string) => void;
}
export declare const NamiPaywallManager: INamiPaywallManager;
14 changes: 6 additions & 8 deletions src/NamiPaywallManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ export interface INamiPaywallManager {
isHidden: () => Promise<boolean>;
isPaywallOpen: () => Promise<boolean>;
setProductDetails: (productDetails: string, allowOffers: boolean) => void;
setAppSuppliedVideoDetails: (url: string, name?: string) => void;
}

const { NamiPaywallManagerBridge, RNNamiPaywallManager } = NativeModules;
Expand Down Expand Up @@ -161,13 +162,10 @@ export const NamiPaywallManager: INamiPaywallManager = {
isPaywallOpen: () => {
return RNNamiPaywallManager.isPaywallOpen();
},
setProductDetails: (
productDetails: string,
allowOffers: boolean
) => {
RNNamiPaywallManager.setProductDetails(
productDetails,
allowOffers,
);
setProductDetails: (productDetails: string, allowOffers: boolean) => {
RNNamiPaywallManager.setProductDetails(productDetails, allowOffers);
},
setAppSuppliedVideoDetails: (url: string, name?: string) => {
RNNamiPaywallManager.setAppSuppliedVideoDetails(url, name);
},
};
4 changes: 4 additions & 0 deletions src/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,9 @@ export type PaywallLaunchContext = {
customAttributes: {
[key: string]: string;
};
customObject?: {
[key: string]: any;
};
};
export type CustomerJourneyState = {
formerSubscriber: boolean;
Expand Down Expand Up @@ -168,6 +171,7 @@ export type NamiPaywallEvent = {
purchaseError?: string;
purchases?: NamiPurchase[];
};
export type NamiPaywallActionHandler = (event: NamiPaywallEvent) => void;
export type NamiPaywallComponentChange = {
id?: string;
name?: string;
Expand Down
8 changes: 6 additions & 2 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ export enum LaunchCampaignError {
PAYWALL_COULD_NOT_DISPLAY = 5,
URL_CAMPAIGN_NOT_FOUND = 6,
PRODUCT_DATA_NOT_FOUND = 7,
PRODUCT_GROUPS_NOT_FOUND = 8
PRODUCT_GROUPS_NOT_FOUND = 8,
}

export enum LaunchCampaignResultAction {
Expand All @@ -196,6 +196,10 @@ export type PaywallLaunchContext = {
customAttributes: {
[key: string]: string;
};
// Custom object used as data source for advanced paywall components
customObject?: {
[key: string]: any;
};
};

export type CustomerJourneyState = {
Expand Down Expand Up @@ -314,7 +318,7 @@ export type NamiPaywallEvent = {
sku?: NamiSKU;
purchaseError?: string;
purchases?: NamiPurchase[];
}
};

export type NamiPaywallActionHandler = (event: NamiPaywallEvent) => void;

Expand Down
Loading