-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
expo: add expo configuration support for batch 2.0
- Loading branch information
1 parent
4873e0e
commit 6228fc2
Showing
6 changed files
with
83 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
import { ConfigPlugin, AndroidManifest, withAndroidManifest } from '@expo/config-plugins'; | ||
|
||
import { | ||
BATCH_DEFAULT_PROFILE_CUSTOM_DATA_MIGRATION, | ||
BATCH_DEFAULT_PROFILE_CUSTOM_ID_MIGRATION, | ||
BATCH_DEFAULT_OPT_OUT_INITIAL_STATE, | ||
} from '../constants'; | ||
import { Props } from '../withReactNativeBatch'; | ||
|
||
export const modifyAndroidManifest = (modResults: AndroidManifest, props: Props): AndroidManifest => { | ||
const profileCustomIdMigrationEnabled = | ||
props.enableProfileCustomIDMigration !== undefined ? props.enableProfileCustomIDMigration : BATCH_DEFAULT_PROFILE_CUSTOM_ID_MIGRATION; | ||
const profileCustomDataMigrationEnabled = | ||
props.enableProfileCustomDataMigration !== undefined | ||
? props.enableProfileCustomDataMigration | ||
: BATCH_DEFAULT_PROFILE_CUSTOM_DATA_MIGRATION; | ||
const defaultOptedOut = props.enableDefaultOptOut !== undefined ? props.enableDefaultOptOut : BATCH_DEFAULT_OPT_OUT_INITIAL_STATE; | ||
modResults.manifest?.application?.map(element => { | ||
if (element['meta-data']) { | ||
element['meta-data'].push({ | ||
$: { | ||
'android:name': 'batch.profile_custom_id_migration_enabled', | ||
'android:value': String(profileCustomIdMigrationEnabled), | ||
}, | ||
}); | ||
element['meta-data'].push({ | ||
$: { | ||
'android:name': 'batch.profile_custom_data_migration_enabled', | ||
'android:value': String(profileCustomDataMigrationEnabled), | ||
}, | ||
}); | ||
element['meta-data'].push({ | ||
$: { | ||
'android:name': 'batch_opted_out_by_default', | ||
'android:value': String(defaultOptedOut), | ||
}, | ||
}); | ||
} | ||
}); | ||
return modResults; | ||
}; | ||
|
||
export const withReactNativeBatchManifest: ConfigPlugin<Props> = (config, props) => { | ||
return withAndroidManifest(config, config => { | ||
config.modResults = modifyAndroidManifest(config.modResults, props); | ||
return config; | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,6 @@ | ||
//Define the version used in the pre-built gradle file for the batch native sdk dependency. | ||
export const BATCH_SDK_VERISON = '1.21.+'; | ||
export const BATCH_SDK_VERSION = '2.0.+'; | ||
export const BATCH_DO_NOT_DISTURB_INITIAL_STATE = false; | ||
export const BATCH_DEFAULT_OPT_OUT_INITIAL_STATE = false; | ||
export const BATCH_DEFAULT_PROFILE_CUSTOM_ID_MIGRATION = true; | ||
export const BATCH_DEFAULT_PROFILE_CUSTOM_DATA_MIGRATION = true; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters