jpush_flutter_plugin_android 0.0.1-alpha.6 copy "jpush_flutter_plugin_android: ^0.0.1-alpha.6" to clipboard
jpush_flutter_plugin_android: ^0.0.1-alpha.6 copied to clipboard

PlatformAndroid

Android implementation of the `jpush_flutter_plugin` that implements `jpush`'s message push service.

example/lib/main.dart

// Copyright (c) 2022, Kimmy
// https://kimmy.me
//
// Use of this source code is governed by an MIT-style
// license that can be found in the LICENSE file or at
// https://opensource.org/licenses/MIT.

import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
import 'package:jpush_flutter_plugin_platform_interface/jpush_flutter_plugin_platform_interface.dart';

Future<void> main() async {
  WidgetsFlutterBinding.ensureInitialized();
  await JpushFlutterPluginPlatform.instance.setDebugMode(debugMode: true);
  await JpushFlutterPluginPlatform.instance.setAuth(auth: true);
  await JpushFlutterPluginPlatform.instance.init('', '',
      (MethodCall call) async {
    print('[method]: ${call.method}');
  });
  Future.delayed(const Duration(seconds: 5), () async {
    await JpushFlutterPluginPlatform.instance
        .setAlias(0, 'gqwyudagdasgcygewyufdgewyuqgdfqwgd');
  });
  runApp(const MyApp());
}

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

  @override
  Widget build(BuildContext context) {
    return const MaterialApp(home: HomePage());
  }
}

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

  @override
  State<HomePage> createState() => _HomePageState();
}

class _HomePageState extends State<HomePage> {
  String? _platformName;

  @override
  Widget build(BuildContext context) {
    return Scaffold(
      appBar: AppBar(title: const Text('JpushFlutterPluginAndroid Example')),
      body: Center(
        child: Column(
          mainAxisAlignment: MainAxisAlignment.center,
          children: [
            if (_platformName == null)
              const SizedBox.shrink()
            else
              Text(
                'Platform Name: $_platformName',
                style: Theme.of(context).textTheme.headline5,
              ),
            const SizedBox(height: 16),
            ElevatedButton(
              onPressed: () async {
                try {
                  final result = await JpushFlutterPluginPlatform.instance
                      .getPlatformName();
                  setState(() => _platformName = result);
                } catch (error) {
                  ScaffoldMessenger.of(context).showSnackBar(
                    SnackBar(
                      backgroundColor: Theme.of(context).primaryColor,
                      content: Text('$error'),
                    ),
                  );
                }
              },
              child: const Text('Get Platform Name'),
            ),
          ],
        ),
      ),
    );
  }
}
0
likes
160
pub points
0%
popularity

Publisher

verified publisherkimmy.me

Android implementation of the `jpush_flutter_plugin` that implements `jpush`'s message push service.

Repository (GitHub)
View/report issues

Documentation

API reference

License

MIT (LICENSE)

Dependencies

flutter, jpush_flutter_plugin_platform_interface

More

Packages that depend on jpush_flutter_plugin_android