Here is the main idea behind this POC:
- The different steps, first we will create a json file that will hold our default information.
- Next when the application first launch’s it will read this file and store the information to memory.
- Afterward we will call an endpoint with an updated version of the XML file and will copy the information of this json into that one if and only if the updated version has a higher version number.
- Next when the UserControl containing the PubCenter ( or something else) ad is called it will read in memory the different values and pass them to the PubCenter element.
But first you need some place to store the file that will hold your information, you can either use your own server or dropbox, because I wanted to go quickly for this POC I used dropbox: https://www.dropbox.com/s/ruoe5dknprvn68d/ExampleAds.txt?dl=1
Now we can really start coding
- You will need to create a file called DefaultAds.txt at the root of your app files, with the following content:
- Then we are going to create a class named AdPubcenterService in which we will add a method called ReadFileFromStorageFile which will luck as follows:
- Now that we can read our file localy we also need to be able to ready our file that is store somewhere on on the web (on dropbox for me). I will create a method call GetAdsFromHttpJsonFiles which will read our local file first, then make a call to our url and save the data for the url.
- The Method ParseElementForAds is what allow us to save information that we have store outside our application. In this method:
- Next we will create a UserControl and add pubcenter XAML to it:
- And when the user control is initialized we will pass our AdI d and AppId to the PubCenter Controller:
And there you have it, you can now manage you Ad Id and App Id from a remote location without having to resubmit your application every time!
Here is the source code: https://onedrive.live.com/redir?resid=70A41C6835F56338!39329&authkey=!ANWpJkTH9Bpn5ho&ithint=file%2czip