Code Monkey home page Code Monkey logo

flutter_wallet's Introduction

flutter_wallet

Donate pub package

Flutter plugin to add pkpass to iOS wallet (Passbook)

Usage

To use, you must at least specify one arguments pkpass.

  • The argument pkpass is List type.

Example

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

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

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

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  Future<void> getPass() async {
    String jsonParameters = '{';
    jsonParameters += '"serialNumber" : "123456789",';
    jsonParameters += '"relevantDate" : "2019-07-20T15:30:00-06:00",';
    jsonParameters += '"latitude" : 19.687,';
    jsonParameters += '"longitude" : -101.151,';
    jsonParameters += '"relevantText" : "Wellcome';
    jsonParameters += '"message" : "QQ2475P",';
    jsonParameters += '"date" : "20 Jul.",';
    jsonParameters += '"time" : "03:30 PM",';
    jsonParameters += '"movie" : "Movie Name",';
    jsonParameters += '"cinema" : "Cinema Name",';
    jsonParameters += '"seats" : "A1",';
    jsonParameters += '"room" : "10",';
    jsonParameters += '"poster" : "https://domain.com/images/image.jpg"';
    jsonParameters += '}';

    Response response;
    Dio dio = new Dio();

    response = await dio.post("http://domain.com/getPKPass.php", 
                          data: jsonParameters, 
                          options: Options(responseType: ResponseType.bytes));

    if (response.data != null) {
      try {
        var result = await FlutterWallet.addPass(pkpass: response.data);
        print(result);
      } catch (e) {
        print(e.message);
      }
    } else {
       print("Data error");
    }
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Passbook example app'),
        ),
        body: Center(
          child: RaisedButton(child: Text("Get Passbook"), onPressed: () {
            getPass();
          },),
        ),
      ),
    );
  }
}

Notes

Don't forget enable Wallet capability in your Xcode project:

And Wallet service in your application service (Certificates, Identifiers & Profiles / Identifiers / App IDs / 'Your app id'):

TODO:

  • Add Android compatibility.
  • Add more documentation.

Getting Started

This project is a starting point for a Flutter plug-in package, a specialized package that includes platform-specific implementation code for Android and/or iOS.

For help getting started with Flutter, view our online documentation, which offers tutorials, samples, guidance on mobile development, and a full API reference.

flutter_wallet's People

Contributors

vico-aguado avatar vicoaguado avatar enolcasielles avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.