Skip to content
Merged
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
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ useEffect(() => {
logLevel: CioLogLevel.debug,
trackApplicationLifecycleEvents: true,
inApp: {
siteId: 'your-site-id', // Required for in-app messaging
siteId: 'your-site-id', // Optional with a pk_ key
},
push: {
android: {
Expand Down
21 changes: 19 additions & 2 deletions __tests__/in-app-site-id.test.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
/**
* `inApp.siteId` stays required, even with a workspace public (`pk_`) key, until the native SDKs
* and the in-app renderer support key-only setup. The JavaScript layer forwards the config as given.
* `inApp.siteId` is optional with a workspace public (`pk_`) key. The JavaScript layer forwards the
* config as given, and the native SDKs start in-app without a site ID when it is left out.
*/

jest.mock('react-native', () => ({
Expand Down Expand Up @@ -56,4 +56,21 @@ describe('in-app site ID', () => {
expect.anything()
);
});

it('forwards an empty inApp config with a pk_ key', async () => {
const config: CioConfig = {
cdpApiKey: 'pk_eu_test-key',
inApp: {},
};

await CustomerIO.initialize(config);

expect(nativeInitialize).toHaveBeenCalledWith(
expect.objectContaining({
cdpApiKey: 'pk_eu_test-key',
inApp: {},
}),
expect.anything()
);
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -265,15 +265,16 @@ class NativeMessagingInAppModule(
builder: CustomerIOBuilder,
config: Map<String, Any>
) {
// Site ID is still required. Native in-app reads the key and region from the CustomerIO setup.
// Site ID is optional with a public (pk_) key. Native in-app reads the key and region from the CustomerIO setup.
val siteId = config.getTypedValue<String>(Keys.Config.SITE_ID)
if (siteId.isNullOrBlank()) {
SDKComponent.logger.error("Site ID is required to initialize InAppMessaging module")
return
val configBuilder = if (siteId.isNullOrBlank()) {
MessagingInAppModuleConfig.Builder()
} else {
MessagingInAppModuleConfig.Builder(siteId = siteId)
}

val module = ModuleMessagingInApp(
MessagingInAppModuleConfig.Builder(siteId = siteId).apply {
configBuilder.apply {
setEventListener(eventListener = ReactInAppEventListener.instance)
colorSchemeFromConfig(config)?.let { colorScheme ->
setColorScheme(colorScheme)
Expand Down
2 changes: 1 addition & 1 deletion api-extractor-output/customerio-reactnative.api.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ export type CioConfig = {
trackApplicationLifecycleEvents?: boolean;
autoTrackDeviceAttributes?: boolean;
inApp?: {
siteId: string;
siteId?: string;
colorScheme?: CioColorScheme;
notificationInboxAccessibilityLabels?: NotificationInboxAccessibilityLabels;
};
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
},
"./package.json": "./package.json"
},
"cioNativeiOSSdkVersion": "= 5.0.0",
"cioNativeiOSSdkVersion": "= 5.1.0",
"files": [
"src",
"lib",
Expand Down
6 changes: 5 additions & 1 deletion src/types/data-pipelines.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,11 @@ export type CioConfig = {
trackApplicationLifecycleEvents?: boolean;
autoTrackDeviceAttributes?: boolean;
inApp?: {
siteId: string;
/**
* Workspace site ID. Optional when `cdpApiKey` is a public `pk_` key, which identifies the
* workspace. Pass `inApp: {}` to turn on in-app messaging without one.
*/
siteId?: string;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we hold this until the iOS release with customerio/customerio-ios#1370 is out and move the iOS pin in this PR? On 5.0.0, build(from:) still throws missingSiteId, so inApp: {} type-checks and works on Android, while iOS logs [InApp] Failed to initialize module and starts without in-app. Same gap #664 had.

/**
* Color scheme used to render in-app messages. Defaults to `CioColorScheme.Auto`, which
* follows the device appearance. Set it when the app has its own appearance setting that
Expand Down
Loading