离子 4 + WhatsApp 分享 - 在我分享我的消息后获取接收者/联系方式



我正在使用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. 如何在返回后立即显示 Toast 消息,以便我知道消息已成功共享?从代码中可以看出,我有一个显示 toast 的 toastService,但它从未被触发。在WhatsApp上成功分享我的消息后,我如何触发吐司,无论是成功还是错误?

要访问联系人,您需要一个单独的插件,例如联系人 - 也许首先使用该插件获取联系人,然后使用shareViaWhatsAppToPhone直接共享到该号码。

吐司应该有效。从您的示例中,您似乎没有将ToastService注入到类中。

最新更新