Skip to content
Draft
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
6 changes: 3 additions & 3 deletions example/ios/NotificationServiceExtension/Env.swift.sample
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
struct Env {
static let CDP_API_KEY = "<API_KEY>"
static let CDP_API_KEY: String = "<API_KEY>"
}

/**
Expand All @@ -11,9 +11,9 @@ struct Env {
/*
struct Env {
#if USE_FCM
static let CDP_API_KEY = "<API_KEY>"
static let CDP_API_KEY: String = "<API_KEY>"
#else
static let CDP_API_KEY = "<API_KEY>"
static let CDP_API_KEY: String = "<API_KEY>"
#endif
}
*/
48 changes: 35 additions & 13 deletions example/src/App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,20 +8,28 @@ import { Storage } from '@services';
import { appTheme } from '@utils';
import { CioConfig, CioPushPermissionStatus, CustomerIO } from 'customerio-reactnative';
import FlashMessage, { showMessage } from 'react-native-flash-message';
import { AppEnvValues } from './env';


// Define minimal type inline since we're bypassing env.ts
type SimpleEnv = {
API_KEY: string;
SITE_ID: string;
buildTimestamp?: number;
};

export default function App({ appName }: { appName: string }) {
const env =
AppEnvValues[appName.toLocaleLowerCase() as keyof typeof AppEnvValues] ??
AppEnvValues['default'];
if (!env) {
console.error(
`No default preset environment variables found nor environment variables for the app: ${appName}. The env.ts contains environment values for case-insenetive app names: ${Object.keys(
AppEnvValues
).join(', ')}`
);
}
Storage.setEnv(env);
// BYPASS ENVIRONMENT FILE COMPLETELY - USE HARDCODED VALUES
const hardcodedEnv: SimpleEnv = {
API_KEY: 'hardcoded_dummy_api_key_12345',
SITE_ID: 'hardcoded_dummy_site_id_67890',
buildTimestamp: 1699999999,
};

// Simple debug string
const debugInfo = `App="${appName}" 🔧HARDCODED_ENV 🔑${hardcodedEnv.API_KEY.substring(0, 10)}...`;

// Set the hardcoded environment
Storage.setEnv(hardcodedEnv);

const [isLoading, setIsLoading] = React.useState(true);

Expand Down Expand Up @@ -50,7 +58,15 @@ export default function App({ appName }: { appName: string }) {
'Initializing CustomerIO on app start with config',
cioConfig
);
CustomerIO.initialize(cioConfig);
try {
CustomerIO.initialize(cioConfig);
console.log('CustomerIO initialized successfully');
} catch (error) {
console.error('Failed to initialize CustomerIO:', error);
// Don't throw - let the app continue to run
}
} else {
console.error('No CustomerIO config found in storage');
}
};
loadFromStorage();
Expand All @@ -59,6 +75,12 @@ export default function App({ appName }: { appName: string }) {
return (
<>
{isLoading && <BodyText>Loading....</BodyText>}
{/* Debug info - remove this after fixing the issue */}
{!isLoading && (
<BodyText style={{fontSize: 10, backgroundColor: 'yellow'}}>
{debugInfo}
</BodyText>
)}
{!isLoading && (
<NavigationCallbackContext.Provider
value={{
Expand Down
18 changes: 10 additions & 8 deletions example/src/env.ts.sample
Original file line number Diff line number Diff line change
@@ -1,31 +1,33 @@
export type Env = {
API_KEY: string;
SITE_ID: string;
buildTimestamp?: number;
};

export const AppEnvValues = {
'default': {
API_KEY: '<API_KEY>',
SITE_ID: '<SITE_ID>',
buildTimestamp: 0,
} satisfies Env,

/**
* If you are switching between Firebase and APN frequently for development,
* Comment out the Env struct above and uncomment the one below
* which will allow you to set API for FCM and APN separately.
* Environment configurations for different app variants
* The keys must match the app names (converted to lowercase) used in the builds
*/
/*
'apn': {
'react native apn': {
API_KEY: '<API_KEY>',
SITE_ID: '<SITE_ID>',
buildTimestamp: 0,
} satisfies Env,
'fcm': {
'react native fcm': {
API_KEY: '<API_KEY>',
SITE_ID: '<SITE_ID>',
buildTimestamp: 0,
} satisfies Env,
'android fcm': {
'react native android': {
API_KEY: '<API_KEY>',
SITE_ID: '<SITE_ID>',
buildTimestamp: 0,
} satisfies Env,
*/
};
Loading