pingidsdk 1.0.0

  • Readme
  • Changelog
  • Example
  • Installing
  • new58

pingidsdk plugin #

Flutter plugin to support PingID SDK Integration. Currently implemented all events and mostly methods of the SDK v1.11.

pub package

Usage #

Add pingidsdk as as dependency and download the PingID SDK Integration Kit. You may need to create an account to do so.

To use the authentication flows, you will also need a linked Firebase project.

Import the package in your .dart file and get the PingIDSDK instance

import 'package:pingidsdk/pingidsdk.dart' as ping;

final ping.PingIDSDK _ping = ping.PingIDSDK.instance;

All PingID SDK events are available throught Streams, so you need to listen for them and after they are no longer needed, you should call .cancel() to prevent leaks.

StreamSubscription<ping.PairingCompleted> _pairingCompletedSub;

@overrride
void initState() {
    super.initState();
    init();
}

Future<void> init() async {
    _pairingCompletedSub = _ping.pairingCompleted.listen((args) async {
      //Pairing completed event called from native code
    });

    //Calling SDK method from Flutter
    bool isTrusted = await _ping.deviceIsTrusted;
}

@override
void dispose() {
    _pairingCompletedSub.cancel();
    super.dispose();
}

For instructions on how does PingID SDK works, please check Ping Identity documentation.

Installation #

Android integration #

  1. Add the PingID_SDK.aar module as PingID_SDK to your project using this instructions.

  2. Update your [project]/android/local.properties file with your PingID application.

...
ping.applicationId=YOUR_APP_ID

If you wish to use authentication as well, you need to also make the following changes:

  1. Using the Firebase Console add an Android app to your project: Follow the assistant, download the generated google-services.json file and place it inside android/app.

  2. Add the classpath to the [project]/android/build.gradle file.

dependencies {
  ...
  // Add the google services classpath
  classpath 'com.google.gms:google-services:4.3.2'
}
  1. Add the apply plugin to the [project]/android/app/build.gradle file.
apply plugin: 'com.google.gms.google-services'
  1. Update your [project]/android/local.properties file with your Firebase's project Push Sender ID.
...
ping.pushSenderId=YOUR_PUSH_SENDER_ID

iOS Integration #

  1. Create the APNS Certificates from your Apple Developer account and upload them to PingOne.

  2. On your project navigator, go to General and then drag the PingID_SDK.xcframework to Frameworks, Libraries, and Embedded Content

  3. Go to Signing & Capabilities and enable Push Notifications and Background Modes -> Remote notifications

  4. You need to create as bridge to PingID ObjC code, you can use the file created by Flutter for that Runner-Bridging-Header.h

#import "GeneratedPluginRegistrant.h"
#import <PingID_SDK/PingId.h>
  1. Add NSLocationWhenInUseUsageDescription to your project's Info.plist

  2. Create a file called Ping.plist with your Ping configuration:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <!-- Your PingID SDK Application ID -->
    <key>APPLICATION_ID</key>
    <string>APP_ID</string>
    <!-- Use Sandbox APNS certificate -->
    <key>DEBUG_CERTIFICATE</key>
    <true/>
</dict>
</plist>

1.0.0 #

  • First release

0.1.0 #

  • Added support for iOS

0.0.3 #

  • No changes made

0.0.2 #

  • Fixed events that received Bundle argument
  • Added PingID related configurations properties to local.properties file
  • Added README file
  • Added license

0.0.1 #

  • Initial package version

example/lib/main.dart

import 'package:flutter/material.dart';
import 'dart:async';

import 'package:pingidsdk/pingidsdk.dart' as ping;

void main() => runApp(MyApp());

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  StreamSubscription<ping.PairingOptionsRequired> _pairingOptionsRequiredSub;
  StreamSubscription<ping.PairingCompleted> _pairingCompletedSub;
  StreamSubscription<dynamic> _authRequiredSub;
  final ping.PingIDSDK _ping = ping.PingIDSDK.instance;
  final String _username = "[username]";

  String _serverPayload = '';
  bool _isTrusted = false;
  bool _needPair = false;
  bool _needAuthorization = false;

  @override
  void initState() {
    super.initState();
    init();
  }

  @override
  void dispose() {
    _pairingOptionsRequiredSub.cancel();
    _pairingCompletedSub.cancel();
    _authRequiredSub.cancel();
    super.dispose();
  }

  Future<void> init() async {
    if (!mounted) return;

    _pairingOptionsRequiredSub =
        _ping.pairingOptionsRequired.listen((args) async {
      //Automatically Approving Pairing
      setState(() {
        _needPair = true;
      });
    });

    _pairingCompletedSub = _ping.pairingCompleted.listen((args) async {
      bool isTrusted = await _ping.deviceIsTrusted;
      setState(() {
        _isTrusted = isTrusted;
        //_needPair = false;
      });
    });

    _authRequiredSub = _ping.authenticationRequired.listen((args) async {
      //Automatically Approving Authentication
      setState(() {
        _needAuthorization = true;
      });
    });

    bool isTrusted = await _ping.deviceIsTrusted;

    setState(() {
      _isTrusted = isTrusted;
    });
  }

  Future<void> _sendServerPayload() async {
    await _ping.sendServerPayload(_serverPayload);
  }

  Future<void> _generatePayload() async {
    String payload = await _ping.payload;
    print(payload);
  }

  Future<void> _pair() async {
    await _ping.pairingSelection(
        _username, ping.TrustLevel.TRUSTED, ping.Action.APPROVE);
    setState(() {
      _needPair = false;
    });
  }

  Future<void> _authorize() async {
    await _ping.authenticationSelection(_username, ping.Action.APPROVE);
    setState(() {
      _needAuthorization = false;
    });
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        ),
        body: Padding(
          padding: const EdgeInsets.all(8.0),
          child: Column(
            children: <Widget>[
              SizedBox(
                height: 20,
              ),
              Text('Is Trusted: ${_isTrusted ? "YES" : "NO"}'),
              SizedBox(
                height: 20,
              ),
              RaisedButton(
                color: Theme.of(context).primaryColor,
                onPressed: _generatePayload,
                child: const Text('Generate Payload'),
              ),
              SizedBox(
                height: 20,
              ),
              TextField(
                onChanged: (value) => setState(() => _serverPayload = value),
              ),
              SizedBox(
                height: 20,
              ),
              RaisedButton(
                color: Theme.of(context).primaryColor,
                onPressed: _sendServerPayload,
                child: const Text('Confirm payload'),
              ),
              SizedBox(
                height: 20,
              ),
              SizedBox(
                height: 20,
              ),
              RaisedButton(
                color: Theme.of(context).primaryColor,
                onPressed: _needPair ? _pair : null,
                child: const Text('Pair'),
              ),
              SizedBox(
                height: 20,
              ),
              RaisedButton(
                color: Theme.of(context).primaryColor,
                onPressed: _needAuthorization ? _authorize : null,
                child: const Text('Authorization'),
              ),
            ],
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  pingidsdk: ^1.0.0

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:pingidsdk/pingidsdk.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
15
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
58
Learn more about scoring.

We analyzed this package on Jul 9, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.4
  • pana: 0.13.14
  • Flutter: 1.17.5

Analysis suggestions

Package does not support Flutter platform linux

Because:

  • package:pingidsdk/pingidsdk.dart that declares support for platforms: android, ios

Package does not support Flutter platform macos

Because:

  • package:pingidsdk/pingidsdk.dart that declares support for platforms: android, ios

Package does not support Flutter platform web

Because:

  • package:pingidsdk/pingidsdk.dart that declares support for platforms: android, ios

Package does not support Flutter platform windows

Because:

  • package:pingidsdk/pingidsdk.dart that declares support for platforms: android, ios

Package not compatible with SDK dart

Because:

  • pingidsdk that is a package requiring null.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.7.0 <3.0.0
flutter 0.0.0
Transitive dependencies
collection 1.14.12 1.14.13
meta 1.1.8 1.2.2
sky_engine 0.0.99
typed_data 1.1.6 1.2.0
vector_math 2.0.8 2.1.0-nullsafety
Dev dependencies
flutter_test