wp_notify 1.0.0 copy "wp_notify: ^1.0.0" to clipboard
wp_notify: ^1.0.0 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 {
    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,
            )
          ],
        ),
      ),
    );
  }
}
22
likes
0
pub points
24%
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

unknown (license)

Dependencies

flutter, http

More

Packages that depend on wp_notify