1

我正在使用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 的 toastService,但它永远不会被触发。在成功和错误情况下,如何在 WhatsApp 上成功分享我的消息后触发 toast?
4

1 回答 1

0

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

吐司应该起作用。从您的示例来看,您似乎没有将 注入ToastService到类中。

于 2019-10-02T11:08:16.730 回答