cordova - 如何在 Ionic/Cordova 中获取搜索广告应用归因 API 信息

标签 cordova ionic-framework apple-search-ads

苹果的Search Ads Attribution API看起来很简单。我想知道是否有一个插件可以实现这一点?

最佳答案

Cordova/Ionic 的 Search Ads API 插件不存在,所以我创建了它。您可以check out the plugin code on Github ,查看Ionic demo app code on Github或者继续阅读有关如何使用它的示例。

You can also check out the step by step tutorial about How to create a native iOS app that can read Search Ads Attribution API information if you're not into hybrid solutions 😯

什么是搜索广告应用归因?

来自Apple's documentation :

Search Ads App Attribution enables developers to track and attribute app downloads that originate from Search Ads campaigns. With Search Ads App Attribution, iOS developers have the ability to accurately measure the lifetime value of newly acquired users and the effectiveness of their advertising campaigns.

如何使用插件

如果您想在空白项目上进行测试,您可以创建一个新的 Ionic 项目,如下所示:

ionic 启动 ionicSearchAdsDemo 选项卡

由于插件已添加到 npm repository ,您可以简单地添加它,如下所示:

ionic 插件添加 cordova-plugin-searchads

DashCtrl Controller 下的controllers.js文件中添加以下代码:

.controller('DashCtrl', function($scope, $ionicPlatform) {
    $scope.data = 'no data';

    $ionicPlatform.ready(function() {
        if (typeof SearchAds !== "undefined") {
            searchAds = new SearchAds();

            searchAds.initialize(function(attribution) {
                console.dir(attribution); // do something with this attribution (send to your server for further processing)
                $scope.data = JSON.stringify(attribution);
            }, function (err) {
                console.dir(err);
            });
        }
    });
})

templates/tab-dash.html 文件的内容替换为:

<ion-view view-title="Dashboard">
  <ion-content class="padding">
    <div class="card">
      <div class="item item-text-wrap">
        {{data}}
      </div>
    </div>
  </ion-content>
</ion-view>

通过在终端中执行以下命令来准备项目:

ionic 准备 ios && 开放平台/ios

之后,打开 XCode 项目 (*.xcodeproj) 文件:

确保 iAd.framework 已添加到链接的框架和库中:

当您添加插件时,这应该会自动发生,但最好确保一下。如果您在此处没有看到它,请自行添加。

在您的设备上运行该项目,您应该得到如下内容:

希望这对某人有用! 💪

关于cordova - 如何在 Ionic/Cordova 中获取搜索广告应用归因 API 信息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46229215/

相关文章:

html - iOS 上滚动 iframe 解决,但 iframe 页面显示不完整

cordova - 如何安装/使用cordova插件?

android - Cordova 错误 : Please install Android target: "android-22" (When I already have 23)

ios - 应用更新后的 Apple 搜索广告

javascript - 删除本地化代码中的 JQuery 依赖

android - Java Restful Web 服务仅运行 Android 4.4 Mobile 而不是其他

angular - 如何在 Ionic-Angular 中传递多个路由参数?

android - ionic update-notifier-cordova.json' 您无权访问此文件

ios - 有什么方法可以使用 Google Analytics 对 Apple Search Ads 安装进行归因吗?