社交分享插件Cordova / Phonegap [英] Social Share Plugin Cordova/Phonegap

查看:141
本文介绍了社交分享插件Cordova / Phonegap的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用的是Cordova的社交分享插件( https://github.com/ bfcam / phonegap-ios-social-plugin ),我有一切工作。我想知道的是,如果有一种方法,有一个图像,你已经或从您的库共享,而不是一个预定义的图像。我已经设置了功能来拍摄照片和从我的图书馆中选择一个图像。感谢。

I am using the Social Share Plugin for Cordova (https://github.com/bfcam/phonegap-ios-social-plugin), and I have everything working. What I was wondering was if there is a way to have an image you have taken or from your library shared instead of a predefined image. I already have the functions set up to take a picture and select an image from my library. Thanks.

我使用这个与ImageFilter插件这里是我的index.html页面的代码

I am using this with an ImageFilter plugin here is the code for my index.html page

<!DOCTYPE html>
<html>
  <head>
  <title></title>

    <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=no;" />
    <meta charset="utf-8">

    <link rel="stylesheet" href="css/style.css">

    <!-- CORE -->
    <script src='js/core/cordova-1.6.0.js'></script>
    <script src='js/core/jQuery.js'></script>

    <!-- PLUGINS -->
   <script src='js/plugins/ImageFilter.js'></script>
   <script src='js/core/social.js'></script>

   <!-- OUR SCRIPTS -->
   <script src='js/init.js'></script>
   <script>
    window.plugins.social.available(function(avail) {
                                if (avail) {
                                // Show social widgets
                                } else {
                                // Social not supported
                                }
                                });
 </script>



 </head>
 <body onload="app.bodyLoad()">
    <div id="header"><img src="images/header.png" width="100%"></div>
<div id="wrapper">
    <div id="content">

        <!-- BUTTONS -->
        <div id="buttons">
            <div class="btn" id="camera" onClick="app.useCamera();">use camera</div>
            <div class="btn" id="roll" onClick="app.useRoll();">use library</div>
            <div class="btn" id="share" onClick="window.plugins.social.share('', '', 'www/images/filters/stark.png');">Share</div>
        </div>
        <!-- END BUTTONS -->

        <!-- IMAGE AREA -->
        <div id="imageArea">
            <!-- OUR IMAGE -->
            <div class="photo"></div>
            <!-- FILTERS -->
            <div id="filters">
                <div class="filter" id="none" onClick="filters.none(largeImage);">
                    <div class="filterIcon"><img src="images/filters/none.png" height="100%"></div>
                    <div class="filterTitle">none</div>
                </div>
                <div class="filter" id="sunnySide" onClick="filters.sunnySide(largeImage);">
                    <div class="filterIcon"><img src="images/filters/sunnySide.png" height="100%"></div>
                    <div class="filterTitle">sunnySide</div>
                </div>
                <div class="filter" id="worn" onClick="filters.worn(largeImage);">
                    <div class="filterIcon"><img src="images/filters/worn.png" height="100%"></div>
                    <div class="filterTitle">worn</div>
                </div>
                <div class="filter" id="vintage" onClick="filters.vintage(largeImage);">
                    <div class="filterIcon"><img src="images/filters/vintage.png" height="100%"></div>
                    <div class="filterTitle">vintage</div>
                </div>
                <div class="filter" id="stark" onClick="filters.stark(largeImage);">
                    <div class="filterIcon"><img src="images/filters/stark.png" height="100%"></div>
                    <div class="filterTitle">stark</div>
                </div>
            </div>
        </div>
        <!-- END IMAGE AREA -->


      </div>
  </div>
</body> 
</html>

这是从图像过滤插件的js,允许我从我的图书馆或tak带有相机的图片

Here is the js from the image filter plugin that allows me to select an image from my library or tak a picture with the camera

var largeImage;

var app = {
    bodyLoad: function () {
        document.addEventListener("deviceready", app.deviceReady, false);
    },
    deviceReady: function () {
        app.init();
    },
    init: function () {

    },
    useCamera: function () {
       navigator.camera.getPicture(app.onCameraSuccess, app.onCameraFail, {
          quality: 100,
        destinationType: Camera.DestinationType.FILE_URI,
        sourceType: Camera.PictureSourceType.CAMERA,
        //allowEdit : true,
        encodingType: Camera.EncodingType.JPEG,
        targetWidth: 910,
        targetHeight: 910,
        saveToPhotoAlbum: false
    });
},
useRoll: function () {
    navigator.camera.getPicture(app.onCameraSuccess, app.onCameraFail, {
        quality: 100,
        destinationType: Camera.DestinationType.FILE_URI,
        sourceType: Camera.PictureSourceType.PHOTOLIBRARY,
        encodingType: Camera.EncodingType.JPEG,
        targetWidth: 910,
        targetHeight: 910,
        saveToPhotoAlbum: false
    });
},
onCameraSuccess: function (imageURI) {

    largeImage = imageURI;
    $(".photo").html("<img src='" + imageURI + "'>");
    $(".photo").show();

},
onCameraFail: function (msg) {
    console.log("ERROR! -" + msg);
}
};

var filters = {
    none: function (imageURI) {
        plugins.ImageFilter.none(filters.rendered, {
           image: imageURI,
           save: 'false',
       });
    },
    sunnySide: function (imageURI) {
        plugins.ImageFilter.sunnySide(filters.rendered, {
            image: imageURI,
            save: 'false'
        });
    },
    worn: function (imageURI) {
        plugins.ImageFilter.worn(filters.rendered, {
            image: imageURI,
            save: 'false'
        });
    },
    vintage: function (imageURI) {
        plugins.ImageFilter.vintage(filters.rendered, {
            image: imageURI,
            save: 'false'
        });
    },
    stark: function (imageURI) {
        plugins.ImageFilter.stark(filters.rendered, {
            image: imageURI,
            save: 'false'
        });
    },
    rendered: function (msg) {

        $(".photo").html("<img src='" + msg + "'>");
    }
}



我遇到了什么参数用来替换' www / image / local_image.jpg',以便它共享我已经或从图书馆选择的图像。

I am struggling with what parameter to use to replace 'www/image/local_image.jpg' in order for it to share the image that I have taken or selected from the library.

推荐答案

该插件的自述文件说明您可以共享以下内容:

The readme file for that plugin says you can share things like this:

window.plugins.social.share('This is the message you want to share', 'http://someurl.com', 'www/image/local_image.jpg');

因此,您应该能够共享任何图像,只需将 image / local_image.jpg'指向要共享的图片的路径。如果您已经有代码来拍摄照片或从您的库中选择图片,这应该是微不足道的。

You should therefore be able to share any image that you have, just replace 'www/image/local_image.jpg' with the path to the image you want to share. If you already have code to take a picture or select an image from your library, this should be trivial.

这篇关于社交分享插件Cordova / Phonegap的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆