Set up ads in Windows Phone 8 - windows-phone

I found a few scattered responses to similar problems (mostly with Windows Phone 7) but wanted to post an answer that contained all requirements for Windows Phone 8 Ads.
I've been having some issues setting an ad up in Windows Phone 8. Every time I ran the emulator I ran into an issue where the app would run but the ad would not show up.
The app ran properly but I noticed in the output console that the following exception was logged:
An exception of type 'Microsoft.Advertising.Shared.AdException' occurred in Microsoft.Advertising.Mobile.DLL and wasn't handled before a managed/native boundary
Ads show up fine in one app I am developing but not another and the exception does not show any helpful information.

I figured out how to catch the exception and see what the issue actually was (which was a large amount of missing capabilities in my Manifest file). In order to try and catch the exception from the AdControl and get the data I needed, I added the following to my page.
Catch Ad Control Errors
public MainPage()
{
InitializeComponent();
AdUnit.ErrorOccurred += AdUnit_ErrorOccurred;
}
void AdUnit_ErrorOccurred(object sender, Microsoft.Advertising.AdErrorEventArgs e)
{
throw new NotImplementedException();
}
Which showed me that I was missing the MEDIALIB permission and the PHONEDIALER permission. I ran some testing and determined that any app that runs ads will require the following permissions:
Required Permissions
ID_CAP_IDENTIFY_USER
ID_CAP_MEDIALIB_PHOTO
ID_CAP_NETWORKING
ID_CAP_PHONEDIALER
ID_CAP_WEBBROWSERCOMPONENT
Set Parameters
From other posts I've read it is also important to make sure you set your ad units width/height properly to 480/80, if it is auto and doesn't have the minimum demensions then the ad will not show.
Make sure that to view it in the emulator you can only use test ApplicationId and AdUnitId. PubCenter credentials will only work in a published application.
<UI:AdControl x:Name="AdUnit" Height="80" Width="480"
AdUnitId="Image480_80" ApplicationId="test_client" />
Hide or Swap Failed/Empty Ad Controls
If your AdControl fails it leaves a big empty space in your ad. You can either hide it or swap it with an ad from another network. To do this, catch the exception as shown above (AdUnit_ErrorOccurred) and added the following:
To Hide:
AdUnit.Height = 0;
AdUnit.Visibility = System.Windows.Visibility.Collapsed;
Setting the visibility didn't work on its own, the height has to be set to 0 as well.
Swap Ad:
Instead of hiding the AdControl, you could show an alternate ad bar from a service like http://www.adduplex.com.

Related

How to detect private browsing in iOS 11 Mobile Safari or MacOS High Sierra Safari?

On the new iOS 11 Safari and MacOS High Sierra Safari, that trick of seeing if window.localStorage.setItem('test', 1); (see https://stackoverflow.com/a/17741714/1330341) throws an error no longer works, because it no longer throws an error, and it also properly sets the localStorage item. Has anyone figured out any other way to check for private browsing mode in the new versions of Safari?
Haven't actually tried it, but from reading Apple's document:
https://support.apple.com/kb/ph21413?locale=en_US
It lists various characteristics of private mode browsing (~snip):
When you use a Private Browsing window:
Each tab in the window is isolated from the others, so websites you
view in one tab can’t track your browsing in other tabs.
Safari doesn’t remember the webpages you visit or your AutoFill
information.
Safari doesn’t store your open webpages in iCloud, so they aren’t
shown when you view all your open tabs from other devices.
Your recent searches aren’t included in the results list when you use
the Smart Search field.
Items you download aren’t included in the downloads list. (The items
do remain on your computer.)
If you use Handoff, Private Browsing windows are not passed to your
iOS devices or other Mac computers.
Safari doesn’t remember changes to your cookies or other website
data. Safari also asks websites and others who provide those sites
with content (including advertisers) not to keep track of your
browsing, although it is up to the websites to honor this request.
Plug-ins that support Private Browsing stop storing cookies and other
tracking information.
From the above, in particular I found interesting that Safari specifically asks websites to "not track" the browsing. This could potentially be a mechanism to look for, to determine if using private browsing.
See this answer for an example:
Implementing Do not track in asp.net mvc
Again, haven't tested and unsure if it will work, but if not the list provides other potential options. HTH.
I find a solution here:
https://gist.github.com/cou929/7973956#gistcomment-2272103
var isPrivate = false;
try {
window.openDatabase(null, null, null, null);
} catch (_) {
isPrivate = true;
}
alert((isPrivate ? 'You\'re' : 'You aren\'t') + ' in private browsing mode');
Hope it helps :)
Quote from apple's website. https://support.apple.com/kb/ph21413?locale=en_US
Websites can’t modify information stored on your device, so services
normally available at such sites may work differently until you turn
off Private Browsing
So, store a test variable, change its value, then read the test variable.
If you get an exception, are unable to find the variable, the value didn't change or you get a null/undefined value back, they are most likely in private mode.
Alternatively, in private browsing, you have no stored search history accessible. So, redirect to a new page in your site on startup and then test if you have any previous history. If not and the fact that you are getting a Do Not Track most likely means your in private mode on safari.
Please note that I have not tested this. This is based off the information provided by Apple in the above link.
Thing that I realized is Safari throws a "Quota Exceeded" error in the Private mode. So here is what I did!
isPrivateMode: function () {
if (localStorage.length === 0) {
try {
localStorage.setItem('isLocalStorageAvaialble', 'That is being tested!');
localStorage.removeItem('isLocalStorageAvaialble');
return false;
} catch (e) {
return true;
}
}
}
Checking the length of localStorage is important for the fact that, if you are trying this method on a browser that supports localStorage, but is full, you still will get the "Quota Exceeded" error.
In private mode, the length of localStorage is always 0.
Hope this helps!

Xcode 7 (iOS 9) Communications error: <OS_xpc_error: <error: 0x10a1abb40>

Can any one help me to figure out the following error I get when I run my application?
Communications error: <OS_xpc_error: <error: 0x10a1abb40> { count = 1,
contents = "XPCErrorDescription" => <string: 0x10a1abef0> { length =
22, contents = "Connection interrupted" } }>
If you are running your app in iOS simulator it uses XPC Services API for interprocess communication and any breakpoint or other interruptions can cause such an error.
You can refer to this Apple Doc
In the section Handling Errors
Interruption handler—called when the process on the other end of the connection has crashed or has otherwise closed its connection.
The debugging of app on device should not have such problems.
I had the same problem when running my app and keyboard extension (I'm building a custom keyboard). Since you do not provide enough information we don't know when this happens to you exactly.. so I'll leave this here in case you are working in an extension too, if not.. hope this will be useful to someone else.
Open the info.plist from your Keyboard Target.
Set Value "Yes" for key "RequestsOpenAccess"
Run your App on device
Go To Settings, General, Keyboard, Keyboards
Select your keyboard
Change "Allow Full Access" to True.
Please pay attention how often you are accessing to the Database.
I also have the same problem. I am working with chat using Firebase. So in my case I made a mistake when I too often get/put data from/into DB.

How do I add my privacy policy link to the Windows Settings charm with Unity?

Windows Store rule 4.1.1 mandate that:
You must provide access to your privacy policy in the Description page
of your app, as well as in the app’s settings as displayed in the
Windows Settings charm.
The Description page is easy, since when you setup your app in the store there's a field where you can enter the URL.
However I'm a bit clueless about how to add this entry in the Windows Setting charm in a Unity project. I've found this answer but that assumes you are in full control and knowledge of your Windows Store app, while I'm just exporting from Unity, so I've no clue on where I would put that code.
So, how do I do that?
Unity is exporting the game as JS or C#.
So have a look to these samples http://code.msdn.microsoft.com/windowsapps/Windows-8-Modern-Style-App-Samples. In these samples, there are a few Setting Charm screnios that you can use in your application.
But remember that, you should add setting charm after export the game.
The plugin prime31/MetroEssentials has the function registerSettingsCommand, which allows you to do just that.
// Registers a settings item with an associated message that will be displaed in a popup when clicked
public static void registerSettingsCommand( string title, string message )
// Registers a settings item with an action. When the settings item is clicked the action will be called.
public static void registerSettingsCommand( string title, Action onActivated )

Microsoft AdControl stealing focus - Windows 8 MonoGame

I am currently writing a simple snake clone game for Windows 8 using MonoGame. I am using the XAML - MonoGame template and trying to include advertising support. I have found an issue, pretty sure it's with the AdControl itself, not MonoGame, however it is stealing keyboard focus every time an ad is loaded.
I have tried to reinitialize the MonoGame 'MetroGameWindow' instance to try and get focus back with no luck. Eg,
void GamePage_LostFocus(object sender, RoutedEventArgs e)
{
MetroGameWindow.Instance.Initialize(Window.Current.CoreWindow,this)
// 'this' is 'GamePage' which inherits from 'SwapChainBackgroundPanel'
}
Does any one know any workarounds for this problem? Any help would be appreciated.
This ia a known problem with AdControl. As of now best solution is to set IsEnabled property of AdControl to false. Doing so will prevent AdControl from taking focus on ad reloads while remaining clickable. See following discussion on bing ads forum: http://community.bingads.microsoft.com/ads/en/publisher/f/63/t/73548.aspx

updating tiles in Win 8 Metro app

Hi in my metro app i have set the wide logo in appxmainfest file and then in page on button click i have written this code
XmlDocument tileXml = TileUpdateManager.GetTemplateContent(TileTemplateType.TileWideText03);
var textElement = tileXml.GetElementsByTagName("text")[0].AppendChild(tileXml.CreateTextNode("Hey This my Text Updated on Tile"));
var tn = new TileNotification(tileXml);
TileUpdateManager.CreateTileUpdaterForApplication().Update(tn);
but at the last line it give me error.
The application identifier provided is invalid.
at Windows.UI.Notifications.TileUpdateManager.CreateTileUpdaterForApplication()
at TilesCS.ScenarioInput1.UpdateTileWithText_Click(Object sender, RoutedEventArgs e) in c:\Users\nitin\Downloads\App tiles and badges sample\C#\ScenarioInput1.xaml.cs:line 68
I tried the sample app by Microsoft but it also has the same issue. I searched other sample app and code but what ever I tried they all gives error.
In one article I read that I need to set some attribute of tile to dynamic but I cant fine it anywhere. Does any one know where I am wrong.
Just solved it. I was running it in simulator where it will give error. But if we run the app in localmachine then it wors fine. So run the app on local machine and not on simulator when working on updating tiles