2

im trying to uses Apples Search Ad api to return the ad data to the app so I can record it. The first attempt produced Apples default data,the next day im getting nil returned on all attributes.

would this have something to do with it? iadAttribution = false

Im testing on a few devices, one has been updated to the latest IOS, All produce the same result.

Please Not the app is not live yet, and im using testing devices!

Any ideas why its returning nil instead of the default data?

Iv been following this tutorial http://www.nikola-breznjak.com/blog/ios/create-native-ios-app-can-read-search-ads-attribution-api-information/

override func loadView() {
        super.loadView()
        getSearchAdsInfo()
    }

 func getSearchAdsInfo(){
    ADClient.shared().requestAttributionDetails({ (attributionDetails, error) in
                if error == nil {
                    for (type, adDictionary) in attributionDetails! {
                        var attribution = adDictionary as? Dictionary<AnyHashable, Any>;
                        let params = [
                            "deviceID": self.appData.deviceInfo,
                            "appID": "self.appData.appID",
                            "iadAdgroupId": attribution?["iad-adgroup-id"] as? String as Any,
                            "iadAdgroupName": attribution?["iad-adgroup-name"] as? String as Any,
                            "iadAttribution": attribution?["iad-attribution"] as? String  as Any,
                            "iadCampaignId": attribution?["iad-campaign-id"] as? String as Any,
                            "iadCampaignName": attribution?["iad-campaign-name"] as? String as Any,
                            "iadClickDate": attribution?["iad-click-date"] as? String as Any,
                            "iadConversionDate": attribution?["iad-conversion-date"] as? String as Any,
                            "iadCreativeId": attribution?["iad-creative-id"] as? String as Any,
                            "iadCreativeName": attribution?["iad-creative-name"] as? String as Any,
                            "iadKeyword": attribution?["iad-keyword"] as? String as Any,
                            "iadLineitemId": attribution?["iad-lineitem-id"] as? String as Any,
                            "iadLineitemName": attribution?["iad-lineitem-name"] as? String as Any,
                            "iadOrgName": attribution?["iad-org-name"] as? String as Any

                            ]
                      print(params)
                    }
                }
            })
}

And the result

    ["iadCampaignName": nil, 
    "iadLineitemName": nil, 
    "iadCreativeId": nil, 
    "iadOrgName": nil, 
    "iadConversionDate": nil, 
    "iadAdgroupName": nil, 
    "iadClickDate": nil, 
    "iadCreativeName": nil, 
    "iadLineitemId": nil, 
    "iadCampaignId": nil, 
    "iadKeyword": nil, 
    "iadAdgroupId": nil, 
    "iadAttribution": Optional("false")]

and print(attributionDetails) produces the following

Optional(["Version3.1": {
    "iad-attribution" = false;
}])
6
  • this casting is not correct can you print attribution and attach it Commented Jun 12, 2018 at 13:40
  • @Sh_Khan not 100% sure what you mean, but iv added the print log of the attributionDetails Commented Jun 12, 2018 at 13:47
  • if this the content of attributionDetails then how you query it for these keys Commented Jun 12, 2018 at 13:49
  • @Sh_Khan Sorry Im pretty new to IOS Development! So Im not totally clued up with the lingo! Im calling this as a function in the loadview on main ViewController Commented Jun 12, 2018 at 13:58
  • the dictionary has no values to the other keys so they are nil Commented Jun 12, 2018 at 14:07

1 Answer 1

1

What worked for me is getting Simulator for iOS version 10.2. With this version dummy data is coming through. I got this:

`Optional([AnyHashable("Version3.1"): {
    "iad-adgroup-id" = 1234567890;
    "iad-adgroup-name" = AdGroupName;
    "iad-attribution" = true;
    "iad-campaign-id" = 1234567890;
    "iad-campaign-name" = CampaignName;
    "iad-click-date" = "2018-06-12T14:56:14Z";
    "iad-conversion-date" = "2018-06-12T14:56:14Z";
    "iad-creative-id" = 1234567890;
    "iad-creative-name" = CreativeName;
    "iad-keyword" = Keyword;
    "iad-lineitem-id" = 1234567890;
    "iad-lineitem-name" = LineName;
    "iad-org-name" = OrgName;
}])

It appears dummy data is not sent in the latest iOS version (in my case 11.4)

Follow this link to get see how to get simulator for older iOS version: https://stackoverflow.com/a/37684633/1072262

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.