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

PlatformAndroid

Lightweight Flutter plugin for honor push integration. Simplifies push notifications on honor devices, supporting token registration, message receiving, and callback handling.

example/lib/main.dart

import 'package:flutter/material.dart';

import 'package:honor_push/honor_push.dart';

void main() {
  runApp(const MyApp());
}

class MyApp extends StatefulWidget {
  const MyApp({super.key});

  @override
  State<MyApp> createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  final _honorPushPlugin = HonorPush();

  String _msg = '';
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
          appBar: AppBar(
            title: const Text('honor_push_example'),
          ),
          body: Center(
            child: Column(
              children: [
                Text(_msg),
                TextButton(
                    onPressed: () {
                      _honorPushPlugin.initialize();
                    },
                    child: Text('initialize')),
                TextButton(
                    onPressed: () async {
                      final resp = await _honorPushPlugin.getToken();
                      if (mounted) {
                        if (null != resp.token) {
                          setState(() {
                            _msg = 'token:${resp.token!}';
                          });
                        } else if (null != resp.errCode) {
                          setState(() {
                            _msg = 'errCode:${resp.errCode!}';
                          });
                        }
                      }
                    },
                    child: Text('getToken')),
                TextButton(
                    onPressed: () async {
                      final resp = await _honorPushPlugin.deleteToken();
                      if (mounted) {
                        if (resp.success) {
                          setState(() {
                            _msg = 'deleteToken:${resp.success}';
                          });
                        } else if (null != resp.errCode) {
                          setState(() {
                            _msg = 'deleteToken errCode:${resp.errCode!}';
                          });
                        }
                      }
                    },
                    child: Text('deleteToken')),
                TextButton(
                    onPressed: () async {
                      final resp =
                          await _honorPushPlugin.getNotificationCenterStatus();
                      if (mounted) {
                        if (resp.success) {
                          setState(() {
                            _msg =
                                'getNotificationCenterStatus:${resp.success}';
                          });
                        } else if (null != resp.errCode) {
                          setState(() {
                            _msg =
                                'getNotificationCenterStatus errCode:${resp.errCode!}';
                          });
                        }
                      }
                    },
                    child: Text('getNotificationCenterStatus')),
                TextButton(
                    onPressed: () async {
                      final resp =
                          await _honorPushPlugin.turnOnNotificationCenter();
                      if (mounted) {
                        if (resp.success) {
                          setState(() {
                            _msg = 'turnOnNotificationCenter:${resp.success}';
                          });
                        } else if (null != resp.errCode) {
                          setState(() {
                            _msg =
                                'turnOnNotificationCenter errCode:${resp.errCode!}';
                          });
                        }
                      }
                    },
                    child: Text('turnOnNotificationCenter')),
                TextButton(
                    onPressed: () async {
                      final resp =
                          await _honorPushPlugin.turnOffNotificationCenter();
                      if (mounted) {
                        if (resp.success) {
                          setState(() {
                            _msg = 'turnOffNotificationCenter:${resp.success}';
                          });
                        } else if (null != resp.errCode) {
                          setState(() {
                            _msg =
                                'turnOffNotificationCenter errCode:${resp.errCode!}';
                          });
                        }
                      }
                    },
                    child: Text('turnOffNotificationCenter')),
              ],
            ),
          )),
    );
  }
}
0
likes
160
points
12
downloads

Publisher

unverified uploader

Weekly Downloads

Lightweight Flutter plugin for honor push integration. Simplifies push notifications on honor devices, supporting token registration, message receiving, and callback handling.

Homepage
Repository (GitHub)
View/report issues

Topics

#honorpush

Documentation

API reference

License

Apache-2.0 (license)

Dependencies

flutter

More

Packages that depend on honor_push

Packages that implement honor_push