77 lines
2.0 KiB
TypeScript
77 lines
2.0 KiB
TypeScript
import { Injectable } from '@angular/core';
|
|
import {Contacts } from "@capacitor-community/contacts";
|
|
import { Plugin} from "@capacitor/core";
|
|
//const { Contacts } = Plugins;
|
|
|
|
import { isPlatform } from "@ionic/angular";
|
|
import {SessionDataProviderService} from "./session-data-provider.service";
|
|
import {WrenchService} from "../services/wrench.service";
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class ContactsDataService {
|
|
|
|
constructor(public sessionDataProviderService:SessionDataProviderService,
|
|
private wrenchService: WrenchService) { }
|
|
|
|
|
|
async refeshContacts(){
|
|
|
|
if (isPlatform('android') || isPlatform('iphone') || isPlatform('ios')){
|
|
//return;
|
|
}
|
|
else{
|
|
return;
|
|
}
|
|
debugger;
|
|
|
|
Contacts.getContacts({projection: {
|
|
name: true,
|
|
phones: true,
|
|
image: true,
|
|
emails: true
|
|
}}).then( result=>{
|
|
this.cacheContactsForAccount(result);
|
|
});
|
|
}
|
|
|
|
usrData: {
|
|
action:number,
|
|
member_id: number,
|
|
uid: string,
|
|
sessionid: string,
|
|
raw_contacts : any
|
|
};
|
|
pPesult:any;
|
|
async cacheContactsForAccount(contactResult){
|
|
alert('AAAA->001');
|
|
this.usrData = {action:22010,
|
|
member_id: this.sessionDataProviderService.member_id,
|
|
uid: this.sessionDataProviderService.member_uid,
|
|
sessionid: this.sessionDataProviderService.session ,
|
|
raw_contacts: JSON.stringify(contactResult.contacts) }
|
|
|
|
alert(this.usrData.uid);
|
|
alert( JSON.stringify( contactResult.toString()) );
|
|
alert(this.usrData.raw_contacts.toString());
|
|
|
|
this.wrenchService.processUsersContacts(this.usrData).subscribe(
|
|
pPesult => {
|
|
this.pPesult = pPesult;
|
|
console.log("pPesult RETURN->", this.pPesult);
|
|
}
|
|
);
|
|
}
|
|
|
|
suggestionTotal:number = 0;
|
|
familyPendingTotalData:any;
|
|
familyPendingData: [];
|
|
|
|
|
|
// async getFamilyPeningData(){
|
|
//
|
|
//
|
|
// }
|
|
}
|