@appier/advid-expo-plugin
v1.0.1
Published
A expo plugin for retrieving advertising id(AAID) on Android.
Downloads
7
Keywords
Readme
appier-advid-expo-plugin
Overview
This plugin is an Expo Config plugin. It extends the Expo config to allow customizing the prebuild phase of managed workflow build which means you don't need to eject to a bare workflow. The purpose of this plugin is to retrieve advertising IDs on Android.
Install
expo install appier-advid-expo-plugin
Configuration
Using expo install appier-advid-expo-plugin
will automatically add the plugin to the plugin array. Please make sure it's the first plugin in the array.
app.json
{
"plugins": [
["appier-advid-expo-plugin", { "targetAndroid12": true }]
]
}
plugin props
You can pass props to configure the plugin according to your environment.
| Prop Name | | Description |
| -- | -- | -- |
| targetAndroid12 | optional | (boolean) If your devices target Android 12 or above, it's necessary to set this prop to true
to ensure the plugin works. This would be false
if targetAndroid12
doesn't provide. |
EAS (Expo Application Services)
To work with managed workflow, EAS is necessary for you to build your project. Follow the document to set up your app. Once you've setup, there should be a eas.json
and you are able to build your app by
eas build --platform android
Usage
Make sure you've already started your custom development client to serve your build from EAS. For more info, please see this document. Basically, the plugin gives you the ability to use our custom native modules call AdvertisingIdModule
.
| Method Name | return | Description| | -- | -- | -- | | getAdId | promise | Get Android Advertising Id
You can then access the module and get the AAID by:
App.js
const { AdvertisingIdModule } = NativeModules;
export default App = () => {
useEffect(()=> {
const getId = async () => {
const id = await AdvertisingIdModule.getAdId();
console.log("id =", id);
}
getId();
}, []}
...
}