FE/IONIC
[ IONIC ] iOS IDFA 추적 동의
HEON.D
2021. 5. 12. 10:32
config.xml
<platform name="ios">
<edit-config file="*-Info.plist" mode="merge" target="NSUserTrackingUsageDescription">
<string>AD tracking</string>
</edit-config>
app.component.ts
// https://www.npmjs.com/package/cordova-plugin-idfa
const idfaPlugin = cordova.plugins.idfa;
idfaPlugin.getInfo()
.then(info => {
if (!info.trackingLimited) {
return info.idfa || info.aaid;
} else if (info.trackingPermission === idfaPlugin.TRACKING_PERMISSION_NOT_DETERMINED) {
return idfaPlugin.requestPermission().then(result => {
if (result === idfaPlugin.TRACKING_PERMISSION_AUTHORIZED) {
return idfaPlugin.getInfo().then(info => {
return info.idfa || info.aaid;
});
} else {
this.storageService.limitAdTracking = true;
this.commonService.alert('[설정] 광고추적 동의 후 충전소를 사용할 수 있습니다.');
}
});
}
})
.then(idfaOrAaid => {
if (idfaOrAaid) {
this.storageService.limitAdTracking = false;
this.storageService.adKey = idfaOrAaid;
}
});