【问题标题】:Ionic Contacts plugin not saving contact on AndroidIonic Contacts 插件未在 Android 上保存联系人
【发布时间】:2019-04-04 00:49:17
【问题描述】:

我尝试在 Android 上保存联系人时遇到问题。它在 iOS 上运行良好,但当我在 Android 上尝试时,应用程序崩溃自行关闭。

我正在使用 Ionic 3 和 Ionic Native Contacts 界面。插件是https://github.com/apache/cordova-plugin-contacts。我知道它说它已被弃用,但我找不到另一个值得信赖的插件。

麻烦的代码是save方法:

let contact: Contact = this.contacts.create();

contact.name = new ContactName(null, 'Smith', 'John');
contact.phoneNumbers = [new ContactField('mobile', '6471234567')];
contact.save().then(
  () => console.log('Contact saved!', contact),
  (error: any) => console.error('Error saving contact.', error)
);

【问题讨论】:

    标签: android ionic-framework plugins contacts


    【解决方案1】:

    有一个帖子对这个问题有解释,基本上你需要替换联系人插件中要求读/写权限的ContactManager.java文件,然后删除android平台并重新添加它。

    This is the updated ContactManager.java

    使用更新版本更新plugins/cordova-plugin-contacts/src/android/ContactManager.java 的文件后,您必须运行:

    ionic cordova platform rm android
    
    ionic cordova platform add android
    

    Here is the original post

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-12-22
      • 2016-10-20
      • 2016-07-28
      • 1970-01-01
      相关资源
      最近更新 更多