简体   繁体   English

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

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

I am using Ionic 4 + SocialSharing-PhoneGap-Plugin . 我正在使用Ionic 4 + SocialSharing-PhoneGap-Plugin

  1. After I share a message with my contact, how can I get back the contact's name/number and other info back in the promise, so that I can save it in the database? 与联系人共享消息后,如何在承诺中取回联系人的姓名/号码和其他信息,以便将其保存在数据库中?

I have the following code: 我有以下代码:

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. How can I show a toast message immediately after return, so that I know that the message was shared successfully? 返回后如何立即显示吐司消息,以便使我知道消息已成功共享? As can be seen from the code, I have a toastService that shows the toast, but it never gets triggered. 从代码中可以看出,我有一个toastService,显示了吐司,但从未触发过。 How can I trigger the toast after successfully sharing my message on WhatsApp, both in success & error cases? 在成功和错误的情况下,如何在WhatsApp上成功共享消息后如何触发敬酒?

To access contacts, you'll need a separate plugin like Contacts -- maybe get the contact first using that plugin and then use shareViaWhatsAppToPhone to share directly to that number. 要访问联系人,您将需要一个单独的插件,例如Contacts -也许首先使用该插件获取联系人,然后使用shareViaWhatsAppToPhone直接共享至该号码。

The toast should work. 烤面包应该起作用。 From your example, it doesn't look like you've injected the ToastService into the class. 从您的示例来看,您似乎没有将ToastService注入到类中。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM