wp_notify 2.0.2 copy "wp_notify: ^2.0.2" to clipboard
wp_notify: ^2.0.2 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/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: 'Wp Notify 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,
            )
          ],
        ),
      ),
    );
  }
}
21
likes
130
pub points
47%
popularity
screenshot

Publisher

verified publisherwoosignal.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-3-Clause (LICENSE)

Dependencies

flutter, nylo_support, pretty_dio_logger

More

Packages that depend on wp_notify