plain_notification_token 0.0.1

  • Readme
  • Changelog
  • Example
  • Installing
  • 85

plain_notification_token #

Get your push notification token via platform way (APNs for iOS / Firebase Clound Messaging for Android)

Getting Started #

Android Integration #

To integrate your plugin into the Android part of your app, setup Firebase:

  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. Modify the android/build.gradle file and the android/app/build.gradle file to add the Google services plugin as described by the Firebase assistant.

(Please see this tutorial if you want.)

iOS Integration #

To integrate your plugin into the iOS part of your app, follow these steps:

  1. Generate the certificates from Apple developer center for receiving push notifications. (Please see this article if you want the tutorial.)
  2. Enable Push Notification in Capabilities tab in Xcode opening your ios/Runner.xcworkspace.

Enabling Push Notification switch

Dart/Flutter Integration #

From your Dart code, you need to import the plugin and instantiate it:

import 'package:plain_notification_token/plain_notification_token.dart';

final plainNotificationToken = PlainNotificationToken();

To get token, call getToken():

// (iOS Only) Need requesting permission of Push Notification.
if (Platform.isIos) {
  // If you want to wait until Permission dialog close,
  // you need wait changing setting registered. 
  await plainNotificationToken.onIosSettingsRegistered.first;

final String token = await plainNotificationToken.getToken();

... and use token on your server!!

Token is Base64 stringified APNs token (in iOS) / Firebase Cloud Messaging (FCM) string token (in Android).

0.0.1 #

  • First release.


import 'dart:async';

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:plain_notification_token/plain_notification_token.dart';

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

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

class _MyAppState extends State<MyApp> {
  String _pushToken = 'Unknown';
  IosNotificationSettings _settings;

  StreamSubscription onTokenRefreshSubscription;
  StreamSubscription onIosSubscription;

  void initState() {

    onTokenRefreshSubscription = PlainNotificationToken().onTokenRefresh.listen((token) {
      setState(() {
        _pushToken = token;
    onIosSubscription = PlainNotificationToken().onIosSettingsRegistered.listen((settings) {
      setState(() {
        _settings = settings;

  void dispose() {

  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: const Text('Plugin example app'),
        body: Center(
          child: Column(
            children: <Widget>[
              Text('token: $_pushToken\n'),
              Text("settings: $_settings"),
                builder: (context) => RaisedButton(
                  child: Text("Request permission"),
                  onPressed: () {
        floatingActionButton: Builder(
          builder: (context) => FloatingActionButton(
                child: Icon(,
                onPressed: () async {
                  String token;
                  // Platform messages may fail, so we use a try/catch PlatformException.
                  try {
                    token = await PlainNotificationToken().getToken();
                  } on PlatformException {
                    token = 'Failed to get platform version.';
                      .showSnackBar(SnackBar(content: Text(token ?? "(no token yet)")));

Use this package as a library

1. Depend on it

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

  plain_notification_token: ^0.0.1

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:plain_notification_token/plain_notification_token.dart';
Describes how popular the package is relative to other packages. [more]
Code health derived from static analysis. [more]
Reflects how tidy and up-to-date the package is. [more]
Weighted score of the above. [more]
Learn more about scoring.

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

  • Dart: 2.7.1
  • pana: 0.13.6
  • Flutter: 1.12.13+hotfix.8

Health suggestions

Format lib/plain_notification_token.dart.

Run flutter format to format lib/plain_notification_token.dart.

Maintenance suggestions

Package is pre-v0.1 release. (-10 points)

While nothing is inherently wrong with versions of 0.0.*, it might mean that the author is still experimenting with the general direction of the API.


Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
platform ^2.2.0 2.2.1
Transitive dependencies
collection 1.14.11 1.14.12
meta 1.1.8
sky_engine 0.0.99
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies