npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@pluritech/ion-facebook-provider

v0.1.0

Published

The wrapper to Facebook Connect plugin from [Ionic Native](https://ionicframework.com/docs/native/facebook/).

Downloads

3

Readme

Wrapper Ionic Facebook

The wrapper to Facebook Connect plugin from Ionic Native.

Installation

First, install the Facebook Connect Plugin from Ionic Native

then install this library, run:

$ npm install @pluritech/ion-facebook-provider --save

Consuming ion-facebook-provider

and then from your Ionic Project AppModule:

import { BrowserModule } from '@angular/platform-browser';
import { NgModule } from '@angular/core';

import { MyApp } from './app.component';

//Is required import the Facebook from Ionic Native
import { Facebook } from '@ionic-native/facebook';
// Import library wrapper 
import { IonFacebookProviderModule } from '@pluritech/ion-facebook-provider';

@NgModule({
  declarations: [
    MyApp
  ],
  imports: [
    BrowserModule,

    // Dont forget put them here
    IonFacebookProviderModule.forRoot(['user_friends', 'email', 'public_profile']),
    Facebook

  ],
  providers: [],
  bootstrap: [AppComponent]
})
export class AppModule { }

The list of permission can set by forRoot. Not required, default is: ['email', 'public_profile']

Once the library is imported, you can use its provider in your Components or Providers:

import { IonFacebookProvider } from '@pluritech/ion-facebook-provider';
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController, private ionFacebookProvider: IonFacebookProvider) {
  }
}

Method login(getPictureBase64?: boolean)

You can use the method Login to make login and receive the datas as userID, accessToken and etc. These method too give you a Header with access token to send to your server.

  • How Use:
import { IonFacebookProvider, FbLoginResponse } from '@pluritech/ion-facebook-provider';
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController, private ionFacebookProvider: IonFacebookProvider) { }

  public loginTest(true) {
    this.ionFacebookProvider.login(true)
    .then((res: FbLoginResponse) => console.log(res))
    .catch(error => console.log(error));
  }
}
  • What there in FbLoginResponse

Field | Can be null | Description ------ | ----------- | ----------- header | false | header with key 'AcessTokenFb' and value as accessToken from authResponse at Facebook picture| true | url picture from user logged in Facebook picture64 | true | picture base 64 from user logged in Facebook if param getPictureBase64 set true and the Facebook allow get url picture

  • FbLoginResponse extends FacebookLoginResponse, see more: https://ionicframework.com/docs/native/facebook/

Method logout()

You can use the method Logout to log the user out from facebook, it's a best practice always call this method when the user quit of your application. See more: Facebook Doc - Logout

import { IonFacebookProvider, FbLoginResponse } from '@pluritech/ion-facebook-provider';
import { Component } from '@angular/core';
import { NavController } from 'ionic-angular';

@Component({
  selector: 'page-home',
  templateUrl: 'home.html'
})
export class HomePage {

  constructor(public navCtrl: NavController, private ionFacebookProvider: IonFacebookProvider) { }

  public logoutTest() {
    this.ionFacebookProvider.logout()
      .then((res) => console.log(res))
      .catch(error => console.log(error));
  }
}

Method getPictureUser(config?: {setBase64?: boolean})

You can get picture of user. Required open session and a token valid to use.

import { IonFacebookProvider, UserPicture } from '@pluritech/ion-facebook-provider';

export class HomePage {

  constructor(public navCtrl: NavController, private ionFacebookProvider: IonFacebookProvider) { }

  public getPictureUser() {
    this.ionFacebookProvider.getPictureUser()
      .then((picture: UserPicture) => console.log(picture))
      .catch(error => console.log(error));
  }
}
  • What there in UserPicture

Field | Can be null | Description ------ | ----------- | ----------- data | false | the data ProfilePictureSource. See more: Profile Picture Source data.base64 | true | If the setBase64 is True, the base 64 of picture will send too:

Method listPermisions()

You get only read list permissions set on root od module.

import { IonFacebookProvider, UserPicture } from '@pluritech/ion-facebook-provider';

export class HomePage {

  constructor(public navCtrl: NavController, private ionFacebookProvider: IonFacebookProvider) { }

  public getListPermission() {
    console.log('getListPermission', this.ionFacebookProvider.listPermisions());
  }
}

Method getPermissions()

You get permissions user from Facebook.

import { IonFacebookProvider, UserPicture } from '@pluritech/ion-facebook-provider';

export class HomePage {

  constructor(public navCtrl: NavController, private ionFacebookProvider: IonFacebookProvider) { }

  public getPermissionUserFacebook() {
    this.ionFacebookProvider.getPermissions()
      .then((permissions: PermissionsUser) => console.log(permissions))
      .catch(error => console.log(error));
  }
}
  • What there in PermissionsUser

The object {key: value} where key is the name of permission and the value is your state that can be ['granted' || 'declined']

Method requestDataByGraphApi(path: string, permissions?: string[])

You can call the methods by API Grap Permissions. See more: Graph API

import { IonFacebookProvider, UserPicture } from '@pluritech/ion-facebook-provider';

export class HomePage {

  constructor(public navCtrl: NavController, private ionFacebookProvider: IonFacebookProvider) { }

  public getGraphAPI() {
    this.ionFacebookProvider.requestDataByGraphApi('/me/photos')
      .then(photos => console.log(photos))
      .catch(error => console.log(error));
  }
}

Development

To generate all *.js, *.d.ts and *.metadata.json files:

$ npm run build

To lint all *.ts files:

$ npm run lint

License

MIT © Lucas Correa