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;
              }
          });

'FE > IONIC' 카테고리의 다른 글

[ IONIC ] 안드로이드 뒤로가기 무효  (0) 2021.04.30
[ IONIC ] 현재 URL  (0) 2021.04.16
[ IONIC ] ionic 5 Slide Effect  (0) 2021.04.15
[ IONIC ] Error MissingDefaultResource  (0) 2021.04.13
[ IONIC ] Android backButton control  (0) 2021.04.05