The AdvertisingInfo module exposes advertising-related information about the device the app is running on.
getAdvertisingId()
To use the AdvertisingInfo module for RN apps, you need to include the module in your app’s UserInit()
as shown in the example below.
For the youi-tv init
app, for example, you can find the UserInit
method in /youi/src/App.cpp
.
#include <youireact/advertising/AdvertisingInfoModule.h>
bool App::UserInit()
{
bool userInitSuccess = PlatformApp::UserInit();
//To use the AdvertisingInfo module
GetReactNativeViewController().AddModule<yi::react::AdvertisingInfoModule>();
return userInitSuccess;
}
import React, { Component } from 'react';
import {
AppRegistry,
StyleSheet,
Text,
View
} from 'react-native';
import { AdvertisingInfo } from '@youi/react-native-youi';
export default class AdvertisingInfoExample extends Component {
state = {
advertisingId: null
}
componentDidMount() {
AdvertisingInfo.getAdvertisingId().then(advertisingId => {
this.setState({advertisingId});
}).catch(error => {
console.log(error);
});
}
render() {
return (
<View style={styles.container}>
<Text style={styles.heading}>AdvertisingInfo exposes advertising related information about the device the app is running on.</Text>
<Text style={styles.text}>Advertising Id: {this.state.advertisingId}</Text>
</View>
);
}
}
const styles = StyleSheet.create({
container: {
flex: 1,
alignItems: 'center',
backgroundColor: '#d0d0d0'
},
heading: {
fontSize: 16
},
text: {
fontSize: 12
}
});
No results yet. Please begin typing a keyword to search the You.i TV Developer Portal...
Try to search with a different keyword or remove search filters.