Is there a way to determine if individuals in my contact list have installed and are using my app? Using Ionic 2

I need the following feature: When a user clicks on the contacts button, they should be able to view all contacts from their device who are currently using the app. Additionally, they should see an "invite" option for contacts who are not yet using the app.

How can I achieve this? I have already installed the contacts Cordova plugin. What steps should I take next; should I implement a filter to identify which contacts on the device are using the same app? I am using the Ionic 2 Framework.

Here is my code snippet:

HOME.TS

findContact(ev: any) {
  let fields: ContactFieldType[] = ['displayName'];

  const options = new ContactFindOptions();
  options.filter = ev.target.value;
  options.multiple = true;
  options.hasPhoneNumber = true;

  Contacts.find(fields, options).then((contacts) => {
    this.contactsfound = contacts;
    console.log(JSON.stringify(contacts[0]));
  });

  if (this.contactsfound.length == 0) {
    this.contactsfound.push({
      displayName: 'No Contacts found'
    });
  }
  this.search = true;
}
Home.HTML
      
<ion-content>
  <ion-searchbar (ionInput)="findContact($event)" placeholder="Enter display name"></ion-searchbar>

  <ion-list [hidden]="!search">
    <ion-item *ngFor="let item of contactsfound">{{item.displayName}}</ion-item>
  </ion-list>

</ion-content>

Answer №1

To achieve this, it is essential to have every user of the application registered on your server. When a new user logs in, their contact list is transmitted to the server for comparison with existing registrations.

Prior to implementing this method, it is recommended to thoroughly research any potential legal implications. There have been reports suggesting that sharing contact information with a server could potentially violate privacy laws.

Similar questions

If you have not found the answer to your question or you are interested in this topic, then look at other similar questions below or use the search

What is the process for clearing a selection from a table?

I have been facing this issue for some time now. I am working with a basic table where selecting a row highlights it. However, I want to enhance my button functionality by adding a "Remove Selection" feature. When clicked, I need the selected row to lose i ...

The parameter type Date cannot be assigned the argument type Moment

import { Moment } from 'moment'; import * as moment from 'moment/moment'; export class JobExecution { public startTime: Moment; constructor() { this.stepExecutions = []; } public get startTimeFormatted(): string { re ...

There was an unhandled rejection error stating: "TypeError - Unable to access property 'push' as it is undefined"

I am encountering an issue while trying to create a function that returns all indexes of an array. I'm not sure what mistake I might be making, as I keep getting an error stating that push cannot be used due to an undefined value. Here's the cod ...

Having trouble with the sx selector not functioning properly with the Material UI DateTimePicker component

I'm currently working with a DateTimePicker component and I want to customize the color of all the days in the calendar to match the theme color: <DateTimePicker sx={{ "input": { color: "primary.main&quo ...

What sets apart the usage of 'export declare function' from 'export function' within a '.d.ts' file?

While reviewing typescript declaration files, I noticed that some people write declarations like this: export function useTheme(): ITheme; I thought that the declare keyword was needed when declaring types for functions defined elsewhere. Is it valid to ...

I'm curious about the type I can set for the first parameter of setState in TypeScript. Is there a way to pass a dynamically generated state object to setState?

When trying to pass a newState object to setState and add some additional properties under certain conditions, I encountered a type error: I attempted to define the new State as Pick<ItemListState, keyof ItemListState> but received a type error ...

Using JSDoc with "T extending Component"

get_matching_components<T extends Component>(component_type_to_return: { new (doodad: Doodad): T }): T[] { return this.components.filter(component => component instanceof component_type_to_return) } In TypeScript, I created a method to retrie ...

Transmit a sequence of keys to the web browser

I'm having difficulty in sending a Shift key command followed immediately by tilde (~). I've attempted various examples, and here's one that I'm currently working on. I am testing the following scenario - selecting a specific image, t ...

Unable to utilize the namespace 'RouteComponentProps' as a specified type

When using TypeScript to define an interface that extends RouteComponentProp, I encountered some issues: VSCode error: [ts] Cannot use namespace "RouteComponentProps" as a type. Console error: Cannot use namespace 'RouteComponentProps' as a typ ...

Exploring the power of indexedDB within a PhoneGap app

I am currently working on developing an offline application using PhoneGap and I need to integrate a local database for this purpose. In my index.js file, which loads the application, I have a global variable. var db; I have a controller that saves the d ...

Exploring the concept of union types and typeguards in TypeScript

I'm struggling with this code snippet: function test(): any[] | string { return [1,2] } let obj: any[] = test(); When I try to run it in vscode, I get the following error message: [ts] Type 'string | any[]' is not assignable to type & ...

Using Typescript to prevent the usage of await with Tslint

Can Tslint be utilized to restrict the usage of Typescript's await feature? If not, are there alternative linters available for this purpose? ...

Incorporate TypeScript into your React projects for improved type

Currently, I am immersing myself in learning React with Typescript. One of the challenges I am facing is related to a specific view I have created. index.tsx import React from 'react' import { CButton } from '@coreui/react' import { us ...

Encountering a problem with chartjs-plugin-annotation in Angular 9

I'm facing a challenge while attempting to create a vertical line on my ng2-charts chart. To accomplish this, I installed the chartjs-plugin-annotation package. However, it seems to be malfunctioning and I am unable to identify the root cause of the i ...

Is there a way to halt the current traversal of visitEachChild in TypeScript Transformer API?

While navigating through each child node of a parent node using visitEachChild, is there a way to stop the process when I no longer wish to visit the subsequent child nodes? For example: Parent node Node 1 Node 2 <-- My target point. Node 3 Node 4 Nod ...

Navigating through SharePoint List data within a customized Skill bot

Seeking assistance with integrating a SharePoint list into my custom virtual assistant skill, developed using the BotFramework V4 template. Initially attempted to access the SharePoint list using CSOM in a custom skill created with .NET core skill templat ...

Error: Attempting to modify the ip property of an #<IncomingMessage> object that is read-only

Currently, I am in the process of developing a middleware that is intended to assign the user's IP address based on the cloudflare header provided. This method has worked successfully on previous projects of mine, but now it seems to be encountering i ...

Issue with SignalR client functionality following update to .NET Core 3.1版本

Upon updating our server-side code to asp.net core 3.1, we encountered an issue with the javascript client for signalr (@microsoft/signalr 3.1.0). The errors we are facing are: https://i.sstatic.net/ITZyK.png Here is the code snippet for the hub initial ...

When Angular encounters :host-context([dir=rtl]) .ion-float-start, it raises a warning about an unmatched pseudo-class in the context of multiple projects within a single angular.json file

I am currently working on an Angular Project that is being used for two different web apps with separate backends. The frontend remains the same for both projects. However, after adding the second project to the angular.json file, I started receiving some ...

When attempting to trigger a function by clicking a button in Angular 8 using HTTP POST, nothing is happening as

I've been struggling to send a POST request to the server with form data using Observables, promises, and xmlhttprequest in the latest Angular with Ionic. It's driving me crazy because either I call the function right at the start and the POST wo ...