首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >当我单击要共享的按钮时,没有加载社会共享。

当我单击要共享的按钮时,没有加载社会共享。
EN

Stack Overflow用户
提问于 2019-12-08 12:53:17
回答 1查看 2K关注 0票数 0

我在离子3上做了SocialSharing插件的分期付款,我安装了离子文档ionic cordova plugin add https://github.com/EddyVerbruggen/SocialSharing-PhoneGap-Plugin.git存储库

但是当我点击按钮的时候,就没什么了。

我尝试过许多方法,但是当我在电话上安装它,并点击按钮,下面的例子方法,没有划线。

home.html:

代码语言:javascript
复制
   <button ion-button block onclick="this.socialSharing.share(null, 'Android filename', 'data:image/png;base64,R0lGODlhDAAMALMBAP8AAP///wAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAACH5BAUKAAEALAAAAAAMAAwAQAQZMMhJK7iY4p3nlZ8XgmNlnibXdVqolmhcRQA7', null)">base64 image only</button>

    <br>

    <button ion-button block onclick="this.socialSharing.shareViaWhatsApp('Message via WhatsApp', null /* img */, null /* url */, function() {console.log('share ok')}, function(errormsg){alert(errormsg)})">msg via WhatsApp (with errcallback)</button>


    <br>


    <button ion-button block onclick="this.socialSharing.canShareVia('whatsapp', 'msg', null, null, null, function(e){alert(e)}, function(e){alert(e)})">is WhatsApp available?</button>

    <br>

    <button ion-fab class="share" mini onclick="this.socialsharing.share('null', 'null', 'https://www.google.nl/images/srpr/logo4w.png', null)">Share</button>

home.ts

代码语言:javascript
复制
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';
import {AlertController} from 'ionic-angular';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
import { SocialSharing } from '@ionic-native/social-sharing/ngx';


declare let DatecsPrinter:any;
declare var window: any;
declare var require: any;
var QRCode = require('qrcode');

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

    DatecsPrinter: any;
    public printerslist;
    public status = "Failure";
    public feedlines:Number = 1;
    listBluetoothDevices:any=[];

    constructor(public navCtrl: NavController, private alertCtrl: AlertController, private iab: InAppBrowser, private socialSharing: SocialSharing) {
        this.getPrintersList();

    }

config.xml

代码语言:javascript
复制
[...]
<plugin name="cordova-plugin-whitelist" spec="1.3.3" />
<plugin name="cordova-plugin-statusbar" spec="2.4.2" />
<plugin name="cordova-plugin-device" spec="2.0.2" />
<plugin name="cordova-plugin-splashscreen" spec="5.0.2" />
<plugin name="cordova-plugin-ionic-webview" spec="^4.0.0" />
<plugin name="cordova-plugin-ionic-keyboard" spec="^2.0.5" />
<plugin name="cordova-plugin-datecs-printer" spec="https://github.com/giorgiofellipe/cordova-plugin-datecs-printer.git" />
<plugin name="cordova-plugin-inappbrowser" spec="3.1.0" />
<plugin name="cordova-plugin-x-socialsharing" spec="^5.17.1" />
<engine name="android" spec="7.1.4" />

app.module.ts:

代码语言:javascript
复制
import { BrowserModule } from '@angular/platform-browser';
import { ErrorHandler, NgModule } from '@angular/core';
import { IonicApp, IonicErrorHandler, IonicModule } from 'ionic-angular';
import { SplashScreen } from '@ionic-native/splash-screen';
import { StatusBar } from '@ionic-native/status-bar';

import { MyApp } from './app.component';
import { HomePage } from '../pages/home/home';
import { InAppBrowser } from '@ionic-native/in-app-browser/ngx';
import { SocialSharing } from '@ionic-native/social-sharing/ngx';


@NgModule({
  declarations: [
    MyApp,
    HomePage
  ],
  imports: [
    BrowserModule,
    IonicModule.forRoot(MyApp)
  ],
  bootstrap: [IonicApp],
  entryComponents: [
    MyApp,
    HomePage
  ],
  providers: [
    StatusBar,
    SplashScreen,
    InAppBrowser,
    SocialSharing,
    {provide: ErrorHandler, useClass: IonicErrorHandler}
  ]
})
export class AppModule {}

以前有人已经有这个问题了?

谢谢!

EN

回答 1

Stack Overflow用户

发布于 2019-12-10 13:20:14

代码语言:javascript
复制
**you calling the function in Html file. move the functions in ts file.**

home.html
<button ion-button block (click)="socialSharing()">base64 image only</button>

home.ts
socialSharing(){
  this.socialSharing.share(
     null, 
    'Android filename', 
    'file', 
    null
  )
}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/59235563

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档