wp_notify 1.0.0
wp_notify: ^1.0.0 copied to clipboard

Send push notification from WordPress using Firebase Cloud Messaging. This package automatically pushes your FCM token to WordPress to start sending notifications. Features include the ability to assi

example/main.dart

import 'package:flutter/material.dart';
import 'package:wp_notify/models/responses/WPStoreTokenResponse.dart';
import 'package:wp_notify/wp_notify.dart';

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

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      title: 'WooSignal Demo',
      theme: ThemeData(
        primarySwatch: Colors.blue,
      ),
      home: MyHomePage(title: 'WooSignal Demo Home Page'),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key? key, this.title}) : super(key: key);

  final String? title;

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  void initState() {
    super.initState();

    // INSTALL THE WP NOTIFY PLUGIN
    // FIRST ON YOUR WORDPRESS STORE
    // LINK https://woosignal.com/plugins/wordpress/wp-notify

    WPNotifyAPI.instance.initWith(baseUrl: "http://mysite.com");
  }

  _storeToken() async {
    try {
      WPStoreTokenResponse wpStoreTokenResponse = WPNotifyAPI.instance.api(
          (request) =>
              request.wpNotifyStoreToken(token: "fcm token", userId: 12));
      print(wpStoreTokenResponse.toJson());
    } on Exception catch (e) {
      print(e);
    }
  }

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(
        title: Text(widget.title),
      ),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: <Widget>[
            MaterialButton(
              child: Text("Store token"),
              onPressed: _storeToken,
            )
          ],
        ),
      ),
    );
  }
}
9
likes
100
pub points
53%
popularity

Publisher

woosignal.com

Send push notification from WordPress using Firebase Cloud Messaging. This package automatically pushes your FCM token to WordPress to start sending notifications. Features include the ability to assign a WordPress user with an FCM token and send push notifications to IOS/Android devices using our API in WordPress.

Homepage
Repository (GitHub)
View/report issues

Documentation

Documentation
API reference

License

BSD (LICENSE)

Dependencies

flutter, http

More

Packages that depend on wp_notify