I’m trying to do a Chrome app with IONIC.
Note: Chrome app is not the same thing as Chrome exension.
In my inspector i have two mains warning that make the app not working…
error 1:
history.pushState is not available in packaged apps.
it is possible to desable ionic History?
error 2:
Refused to load the image ‘unsafe:chrome-extension://fdfjjnapgsgsgsgsegegselgpmf/img/ben.png’ because it violates the following Content Security Policy directive: “img-src ‘self’ blob: filesystem: data: chrome-extension-resource:”.
Is there a way to fix that?
I did find out how to fix the image security issue but not the navigation one.
I found out something here talking about this issue but i did try it and it do not work. i may not have implemented it the right way.
.config(function($provide) {
$provide.decorator('$window', function($delegate) {
Object.defineProperty($delegate, 'history', {get: () => null});
return $delegate;
});
});
// Or using the `.decorator()` helper:
.decorator('$window', function($delegate) {
Object.defineProperty($delegate, 'history', {get: () => null});
return $delegate;
});
I tryed this sniffer.js thing but nope.
sniffer.js
Ok, i did it, i’m talking here alone to myself but if ever someone need it, here what i did to make IONIC work in a Chrome app.
/* GC - CHROME - SHOWING INTERNAL IMAGES A MAKE THE NAVIGATION WORK */
.config(['$compileProvider', function ($compileProvider) {
$compileProvider.imgSrcSanitizationWhitelist(/^\s*(https?|ftp|file|content|blob)|data:image\/|\/?img\//);
$compileProvider.aHrefSanitizationWhitelist(/^\s*(https?|ftp|mailto|file|ghttps?|ms-appx|chrome-extension)|\/?app\//);
}])
/*************************************************/
/* GC - CHROME - DISABLE HISTORY PUSH */
.config(['$provide', function ($provide) {
$provide.decorator('$window', function ($delegate) {
Object.defineProperty($delegate, 'history', {
get: () => null
});
return $delegate;
});
}])
/************************************/
CSS: make the header dragable but not the back button
ion-header-bar {
-webkit-app-region: drag;
}
.nodrag {
-webkit-app-region: no-drag;
}