fake_push 0.2.0+1 copy "fake_push: ^0.2.0+1" to clipboard
fake_push: ^0.2.0+1 copied to clipboard

discontinued
outdated

A powerful tencent xinge push plugin for Flutter.

example/lib/main.dart

import 'dart:async';
import 'dart:io';

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

void main() {
  runZoned(() {
    runApp(MyApp());
  }, onError: (Object error, StackTrace stack) {
    print(error);
    print(stack);
  });

  if (Platform.isAndroid) {
    SystemUiOverlayStyle systemUiOverlayStyle =
        const SystemUiOverlayStyle(statusBarColor: Colors.transparent);
    SystemChrome.setSystemUIOverlayStyle(systemUiOverlayStyle);
  }
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    Push push = Push();
    push.registerApp().then((_) {
      push.startWork(enableDebug: !_isReleaseMode());
      push.areNotificationsEnabled().then((bool isEnabled) {
        if (!isEnabled) {
          push.requestNotificationsPermission();
        }
      });
    });
    return PushProvider(
      push: push,
      child: MaterialApp(
        home: Home(),
      ),
    );
  }

  bool _isReleaseMode() {
    return bool.fromEnvironment('dart.vm.product');
  }
}

class Home extends StatefulWidget {
  @override
  State<StatefulWidget> createState() {
    return _HomeState();
  }
}

class _HomeState extends State<Home> {
  @override
  Widget build(BuildContext context) {
    return PushWidget(
      push: PushProvider.of(context).push,
      messageHandler: _handleMessage,
      notificationHandler: _handleNotification,
      launchNotificationHandler: _handleLaunchNotificationHandler,
      resumeNotificationHandler: _handleResumeNotificationHandler,
      builder: (BuildContext context) {
        return Scaffold(
          appBar: AppBar(
            title: const Text('Fake Push Demo'),
          ),
          body: Center(
            child: GestureDetector(
              child: Text('${Platform.operatingSystem}'),
              onTap: () {},
            ),
          ),
        );
      },
    );
  }

  void _handleMessage(Map<dynamic, dynamic> map) {
    print('message $map');
  }

  void _handleNotification(Map<dynamic, dynamic> map) {
    print('notification $map');
  }

  void _handleLaunchNotificationHandler(Map<dynamic, dynamic> map) {
    print('launchNotification $map');
  }

  void _handleResumeNotificationHandler(Map<dynamic, dynamic> map) {
    print('resumeNotification $map');
  }
}
3
likes
0
pub points
0%
popularity

Publisher

verified publisherhaitanyule.com

A powerful tencent xinge push plugin for Flutter.

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

flutter, meta

More

Packages that depend on fake_push