wp_notify 0.0.1 copy "wp_notify: ^0.0.1" to clipboard
wp_notify: ^0.0.1 copied to clipboard

outdated

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 {
    WPStoreTokenResponse wpStoreTokenResponse;
    try {
      wpStoreTokenResponse = WPNotifyAPI.instance.api((request) => request.wpNotifyStoreToken(token: "fcm token", userId: 12));
    } 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
30
pub points
49%
popularity

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

License

BSD-3-Clause (LICENSE)

Dependencies

flutter, http

More

Packages that depend on wp_notify