Abd*_*der 2 jquery-mobile cordova
我想截取应用程序屏幕截图(结果页面),然后想要在社交媒体上分享.我尝试使用https://github.com/gitawego/cordova-screenshot但它给我一个错误http://i.imgur.com/PktJJQI.png.我正在使用phonegap 3.4.0.
在您的应用程序中安装以下插件
cordova plugin add https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git
Run Code Online (Sandbox Code Playgroud)
和
cordova plugin add https://github.com/gitawego/cordova-screenshot.git
Run Code Online (Sandbox Code Playgroud)
通过将'cordova'替换为'phonegap local',可以类似地安装PhoneGap的插件
安装插件后,通过执行准备项目
$ cordova prepare
Run Code Online (Sandbox Code Playgroud)
在脚本中添加以下代码:
<script>
function sharePhoto() {
var imageLink;
console.log('Calling from CapturePhoto');
navigator.screenshot.save(function(error,res){
if(error){
console.error(error);
}else{
console.log('ok',res.filePath); //should be path/to/myScreenshot.jpg
//For android
imageLink = res.filePath;
window.plugins.socialsharing.share(null, null,'file://'+imageLink, null);
//For iOS
//window.plugins.socialsharing.share(null, null,imageLink, null)
}
},'jpg',50,'myScreenShot');
}
</script>
Run Code Online (Sandbox Code Playgroud)
按下按钮调用上面的功能如下:
<button onclick="sharePhoto();">Share Screenshot</button>
Run Code Online (Sandbox Code Playgroud)
如果您无法看到登录控制台,请安装以下插件并再次准备您的项目.
cordova plugin add https://git-wip-us.apache.org/repos/asf/cordova-plugin-console.git
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4556 次 |
| 最近记录: |