nim_chatkit_pushkit 10.9.0 copy "nim_chatkit_pushkit: ^10.9.0" to clipboard
nim_chatkit_pushkit: ^10.9.0 copied to clipboard

Push notification click bridge and default NIM payload helpers for ChatKit.

example/lib/main.dart

// Copyright (c) 2022 NetEase, Inc. All rights reserved.
// Use of this source code is governed by a MIT license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:flutter/material.dart';
import 'package:nim_chatkit_pushkit/nim_chatkit_pushkit.dart';

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

class MyApp extends StatefulWidget {
  // ignore: use_super_parameters
  const MyApp({Key? key}) : super(key: key);

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

class _MyAppState extends State<MyApp> {
  StreamSubscription<PushKitMessage>? _subscription;
  PushKitMessage? _lastMessage;

  @override
  void initState() {
    super.initState();
    _initPushKit();
  }

  Future<void> _initPushKit() async {
    await PushKit.instance.init();
    _subscription = PushKit.instance.onNotificationClick.listen((message) {
      if (!mounted) return;
      setState(() {
        _lastMessage = message;
      });
    });
    final initialMessage = await PushKit.instance.getInitialNotification();
    if (!mounted || initialMessage == null) return;
    setState(() {
      _lastMessage = initialMessage;
    });
  }

  @override
  void dispose() {
    _subscription?.cancel();
    super.dispose();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(title: const Text('PushKit example')),
        body: Padding(
          padding: const EdgeInsets.all(16),
          child: Text('Last push click: ${_lastMessage?.toMap()}'),
        ),
      ),
    );
  }
}
0
likes
150
points
10
downloads

Documentation

API reference

Publisher

unverified uploader

Weekly Downloads

Push notification click bridge and default NIM payload helpers for ChatKit.

Repository (GitHub)
View/report issues

License

MIT (license)

Dependencies

flutter, netease_corekit, nim_chatkit, nim_core_v2, plugin_platform_interface

More

Packages that depend on nim_chatkit_pushkit

Packages that implement nim_chatkit_pushkit