trentclowater trentclowater - 5 months ago 17
AngularJS Question

Angular Js and Trigger.io - Can't follow a link on Android that works on iOS

I am using AngularJS with Trigger.io to develop a mobile application for both iOS and Android.

When I try to open a link that looks like this:

<a ng-href="#/offers/{{featured_offer.Id}}"></a>


It works perfectly fine on iOS, but on Android I get this message in the trigger console, and the link is not navigated to:

[WARNING] Attempted to open a URL which could not be handled: unsafe:content://io.trigger.forge722b6464a0e211e2ba9d12313d00dc45/src/index.html#/offers/8


How can I get this to work in Android the same as it works in iOS?

Answer

Looks like Angular adds unsafe: to url schemes it doesn't recognise, I think you want to include something like:

app.config(function($compileProvider){
  $compileProvider.urlSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|tel|content):/);
});

Which adds content: to the accepted url schemes.