使用ngCordova的社交分享插件。 使用config.xml手动安装它:https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin/blob/master/README.md 每当我尝试使用以下函数时,它总是进入函数(错误)
查看代码:
<ion-pane>
<ion-header-bar class="bar-calm">
<h1 class="title">SMS</h1>
</ion-header-bar>
<ion-content class="has-header">
<ion-list>
<label class="item item-input item-input-stacked item-stable">
<span class="input-label"></span>
<input type="number" placeholder="Your number" ng-model="sms.num">
</label>
<label class="item item-input item-input-stacked item-stable">
<span class="input-label"></span>
<input type="text" placeholder="Your message" ng-model="sms.msg">
</label>
<button class="button button-block button-dark" ng-click="send()"> Send </button>
<button class="button button-block button-dark" ng-click="social()"> Social </button>
</ion-list>
</ion-content>
</ion-pane>
Angular Code:
.controller('ctrl', function($scope,$cordovaSms,$cordovaSplashscreen,$cordovaSocialSharing){
$scope.social = function(){
$cordovaSocialSharing.share("This is your message", "This is your subject", "www/img/ionic.png", "https://www.google.com")
.then(
function(result) {
console.log("Success");
console.log(result);
},
function(err) {
// An error occurred. Show a message to the user
console.log("error : "+err);
}
);
}
});
答案 0 :(得分:1)
使用此代码它对我有用
第1步:将此插件添加到config.xml文件
<gap:plugin name="cordova-plugin-x-socialsharing" source="npm" />
第二步:在社交功能下添加此代码
window.plugins.socialsharing.share('Choose The App','Share It','www/img/ionic.png', 'http://www.x-services.nl');
答案 1 :(得分:0)
使用下面的代码来形成我。我用过whatsup
window.plugins.socialsharing.shareViaWhatsApp(text, 'image', null, function() {}, function(errormsg) {});
答案 2 :(得分:0)
错误已解决。 这是一个Android构建错误。 我不得不在build.gradle文件中添加一个依赖项。
dependencies {
//
// IDE setting pulls in the specific version of v4 support you have installed:
//
//compile 'com.android.support:support-v4:21.0.3'
//
// generic directive pulls in any available version of v4 support:
//
compile 'com.android.support:support-v4:+'
}
然后通过CLI再次安装它,它工作正常。 谢谢。