apns_flutter 0.0.2 icon indicating copy to clipboard operation
apns_flutter: ^0.0.2 copied to clipboard

Use Flutter to interact with the native push notifications system on iOS.

example/lib/main.dart

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

void main() {
  runApp(MyApp());
}

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

class _MyAppState extends State<MyApp> {
  final apns = ApnsFlutter();

  String token;

  void register() async {
    apns.onToken((token) {
      setState(() {
        this.token = token;
      });
    });
    apns.register(badge: true, alert: true, sound: true);
  }

  @override
  Widget build(BuildContext context) {
    if (token == null) {
      return MaterialApp(
        home: Scaffold(
          appBar: AppBar(
            title: const Text('Flutter APNS Example'),
            actions: <Widget>[
              FlatButton(
                child: Text("Get Token"),
                onPressed: () {
                  register();
                },
              ),
            ],
          ),
          body: Center(
            child: Text("Token not received.", style: TextStyle(fontSize: 20)),
          ),
        ),
      );
    } else {
      return MaterialApp(
        home: Scaffold(
          appBar: AppBar(
            title: const Text('Flutter APNS Example'),
          ),
          body: Center(
            child: Text(token, style: TextStyle(fontSize: 20)),
          ),
        ),
      );
    }
  }
}
1
likes
100
pub points
3%
popularity

Publisher

verified publisher iconwrenn.me

Use Flutter to interact with the native push notifications system on iOS.

Repository (GitHub)

Documentation

API reference

License

Icon for licenses.unknown (LICENSE)

Dependencies

flutter

More

Packages that depend on apns_flutter