jgpush_service.dart 1.1 KB

123456789101112131415161718192021222324252627282930313233
  1. import 'package:jpush_flutter/jpush_flutter.dart';
  2. import 'package:lszlgl/config/app_config.dart';
  3. class JGPushService{
  4. static final JPush jPush = JPush();
  5. static Future<void> jgInit(AppEnvironment env) async{
  6. jPush.setup(
  7. // 极光推送 正式环境appkey需要再申请
  8. appKey: env == AppEnvironment.product ? '2f42e3db4d0083b0bc5a3f6c' : '2f42e3db4d0083b0bc5a3f6c',
  9. channel: 'developer-default',
  10. production: env == AppEnvironment.product ? true : false,
  11. debug: env == AppEnvironment.develop ? true : false
  12. );
  13. jPush.addEventHandler(
  14. // 接收通知回调方法。
  15. onReceiveNotification: (Map<String, dynamic> message) async {
  16. print("flutter onReceiveNotification: $message");
  17. },
  18. // 点击通知回调方法。
  19. onOpenNotification: (Map<String, dynamic> message) async {
  20. print("flutter onOpenNotification: $message");
  21. },
  22. // 接收自定义消息回调方法。
  23. onReceiveMessage: (Map<String, dynamic> message) async {
  24. print("flutter onReceiveMessage: $message");
  25. },
  26. );
  27. }
  28. }