diff --git a/example/ios/NotificationServiceExtension/Env.swift.sample b/example/ios/NotificationServiceExtension/Env.swift.sample index 4f2157d8..f6536c0d 100644 --- a/example/ios/NotificationServiceExtension/Env.swift.sample +++ b/example/ios/NotificationServiceExtension/Env.swift.sample @@ -1,5 +1,5 @@ struct Env { - static let CDP_API_KEY = "" + static let CDP_API_KEY: String = "" } /** @@ -11,9 +11,9 @@ struct Env { /* struct Env { #if USE_FCM - static let CDP_API_KEY = "" + static let CDP_API_KEY: String = "" #else - static let CDP_API_KEY = "" + static let CDP_API_KEY: String = "" #endif } */ \ No newline at end of file diff --git a/example/src/App.tsx b/example/src/App.tsx index f7a6eabb..2df360c5 100644 --- a/example/src/App.tsx +++ b/example/src/App.tsx @@ -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); @@ -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(); @@ -59,6 +75,12 @@ export default function App({ appName }: { appName: string }) { return ( <> {isLoading && Loading....} + {/* Debug info - remove this after fixing the issue */} + {!isLoading && ( + + {debugInfo} + + )} {!isLoading && ( ', 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: '', SITE_ID: '', + buildTimestamp: 0, } satisfies Env, - 'fcm': { + 'react native fcm': { API_KEY: '', SITE_ID: '', + buildTimestamp: 0, } satisfies Env, - 'android fcm': { + 'react native android': { API_KEY: '', SITE_ID: '', + buildTimestamp: 0, } satisfies Env, - */ };