簡體   English   中英

Ionic 4 + WhatsApp分享-分享信息后獲取收件人/聯系方式

[英]Ionic 4 + WhatsApp share - Get receiver / contact details after I share my message

我正在使用Ionic 4 + SocialSharing-PhoneGap-Plugin

  1. 與聯系人共享消息后,如何在承諾中取回聯系人的姓名/號碼和其他信息,以便將其保存在數據庫中?

我有以下代碼:

import { SocialSharing } from '@ionic-native/social-sharing/ngx';

constructor(private socialSharing: SocialSharing) { }

// Share message via WhatsApp
this.socialSharing.shareViaWhatsApp('Hi', null, null).then(() => {
  // How to get the contact's details here, with whom
 // I shared my message? Would like to get the name, number 
 // and all other contact info.

// Following Toast does not seem to trigger
this.toastService.presentToast('Successfully shared coupon on WhatsApp', 'success');
}).catch(() => {
  // Sharing via WhatsApp is not possible. How to trigger a toast here as well?
});
  1. 返回后如何立即顯示吐司消息,以便使我知道消息已成功共享? 從代碼中可以看出,我有一個toastService,顯示了吐司,但從未觸發過。 在成功和錯誤的情況下,如何在WhatsApp上成功共享消息后如何觸發敬酒?

要訪問聯系人,您將需要一個單獨的插件,例如Contacts -也許首先使用該插件獲取聯系人,然后使用shareViaWhatsAppToPhone直接共享至該號碼。

烤面包應該起作用。 從您的示例來看,您似乎沒有將ToastService注入到類中。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM