Created
May 10, 2016 06:48
-
-
Save marcusasplund/b3cfd94c1ff218da20124ecc0105030c to your computer and use it in GitHub Desktop.
Resolve native imagepath in ionic2 with cordova-plugin-filepath
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// with this plugin: | |
// https://github.com/hiddentao/cordova-plugin-filepath/ | |
initializeApp() { | |
this | |
.platform | |
.ready() | |
.then(() => { | |
if (window.StatusBar) { | |
window | |
.StatusBar | |
.styleDefault(); | |
} | |
if (window.plugins && window.plugins.webintent) { | |
window | |
.plugins | |
.webintent | |
.getExtra(window.plugins.webintent.EXTRA_STREAM, (data) => { | |
console.log(data); | |
this.getProperImageUrl(data); | |
}, (error) => { | |
console.log(error); | |
}); | |
} | |
}); | |
} | |
getProperImageUrl(data) { | |
window | |
.FilePath | |
.resolveNativePath(data, this.openCameraPageOnSuccess, this.errorCallback); | |
} | |
openCameraPageOnSuccess(realPath) { | |
console.log(realPath); | |
let image = [ | |
{ | |
src: realPath | |
} | |
]; | |
let nav = this | |
.app | |
.getComponent('nav'); | |
nav.push(CameraPage, {images: image}); | |
} | |
errorCallback(data) { | |
console.log(data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment