Skip to content

Commit 2b35bfe

Browse files
committed
chore: remove getApiKey function and update README for environment variable usage
1 parent 36a50b2 commit 2b35bfe

File tree

11 files changed

+11
-42
lines changed

11 files changed

+11
-42
lines changed

android/src/main/java/expo/modules/adapters/iterable/ExpoAdapterIterableModule.kt

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,5 @@ import android.content.pm.PackageManager
77
class ExpoAdapterIterableModule() : Module() {
88
override fun definition() = ModuleDefinition {
99
Name("ExpoAdapterIterable")
10-
11-
/**
12-
* Get the Iterable API key from the AndroidManifest.xml file.
13-
* @return The Iterable API key.
14-
*/
15-
Function("getApiKey") {
16-
val applicationInfo = appContext?.reactContext?.packageManager?.getApplicationInfo(appContext?.reactContext?.packageName.toString(), PackageManager.GET_META_DATA)
17-
18-
return@Function applicationInfo?.metaData?.getString("ITERABLE_API_KEY")
19-
}
2010
}
2111
}

example/.env

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
EXPO_PUBLIC_ITERABLE_API_KEY=YOUR_ITERABLE_API_KEY
2+
EXPO_PUBLIC_ITERABLE_EMAIL=YOUR_ITERABLE_EMAIL

example/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ Expo.
4040
yarn install
4141
```
4242
3. Configure your Iterable API key:
43-
- Open `app.json`
44-
- Replace `YOUR_API_KEY` with your actual Iterable API key
43+
- Copy `.env` to `.env.local`
44+
- Replace `YOUR_ITERABLE_API_KEY` with your actual Iterable API key
4545

4646
4. For Android push notifications:
4747
- Place your `google-services.json` file in the root of the example directory

example/app.json

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@
6767
[
6868
"../app.plugin.js",
6969
{
70-
"apiKey": "YOUR_ITERABLE_API_KEY",
7170
"appEnvironment": "development",
7271
"autoConfigurePushNotifications": true,
7372
"enableInAppMessages": true,

example/src/Login.tsx

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import { getApiKey } from '@iterable/expo-plugin';
21
import {
32
Iterable,
43
IterableConfig,
@@ -44,7 +43,10 @@ export const Login = ({ onLoggedIn = () => {} }: LoginProps) => {
4443

4544
config.inAppHandler = () => IterableInAppShowResponse.show;
4645

47-
Iterable.initialize(getApiKey(), config).finally(() => {
46+
Iterable.initialize(
47+
process.env.EXPO_PUBLIC_ITERABLE_API_KEY as string,
48+
config
49+
).finally(() => {
4850
setInitialized(true);
4951
});
5052
}, []);

ios/ExpoAdapterIterableModule.swift

Lines changed: 1 addition & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,5 @@ import ExpoModulesCore
33
public class ExpoAdapterIterableModule: Module {
44
public func definition() -> ModuleDefinition {
55
Name("ExpoAdapterIterable")
6-
7-
/**
8-
* Get the Iterable API key from the Info.plist file.
9-
* @return The Iterable API key.
10-
*/
11-
Function("getApiKey") {
12-
return Bundle.main.object(forInfoDictionaryKey: "ITERABLE_API_KEY") as? String
13-
}
146
}
15-
}
7+
}

plugin/src/index.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@ const withIterable: ConfigPlugin<ConfigPluginProps> = (config, props = {}) => {
1212
// Set default values for props
1313
const propsWithDefaults: ConfigPluginPropsWithDefaults = {
1414
...props,
15-
apiKey: props.apiKey ?? '',
1615
appEnvironment: props.appEnvironment ?? 'development',
1716
autoConfigurePushNotifications:
1817
props.autoConfigurePushNotifications ?? true,

plugin/src/withIterable.types.ts

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,4 @@
11
export interface ConfigPluginProps {
2-
/**
3-
* The api key for the Iterable project.
4-
*/
5-
apiKey?: string;
62
/**
73
* The environment of the app.
84
* @default 'development'

plugin/src/withStoreConfigValues.ts

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ import { type ConfigPluginPropsWithDefaults } from './withIterable.types';
1515
*/
1616
type JsKey = keyof Pick<
1717
ConfigPluginPropsWithDefaults,
18-
'apiKey' | 'requestPermissionsForPushNotifications' | 'enableInAppMessages'
18+
'requestPermissionsForPushNotifications' | 'enableInAppMessages'
1919
>;
2020

2121
/**
@@ -32,7 +32,6 @@ type NativeKey = string;
3232
* Info.plist file or the AndroidManifest.xml file.
3333
*/
3434
const nativeKeyMap: Record<JsKey, NativeKey> = {
35-
apiKey: 'ITERABLE_API_KEY',
3635
requestPermissionsForPushNotifications:
3736
'ITERABLE_REQUEST_PERMISSIONS_FOR_PUSH_NOTIFICATIONS',
3837
enableInAppMessages: 'ITERABLE_ENABLE_IN_APP_MESSAGES',

src/ExpoAdapterIterableModule.ts

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
11
import { NativeModule, requireNativeModule } from 'expo';
22

3-
declare class ExpoAdapterIterableModule extends NativeModule {
4-
/**
5-
* Get the Iterable API key set in the expo config.
6-
* @return The Iterable API key.
7-
*/
8-
getApiKey(): string;
9-
}
3+
declare class ExpoAdapterIterableModule extends NativeModule {}
104

115
// This call loads the native module object from the JSI.
126
export default requireNativeModule<ExpoAdapterIterableModule>(

0 commit comments

Comments
 (0)