import 'package:jpush_flutter/jpush_flutter.dart'; import 'package:lszlgl/config/app_config.dart'; class JGPushService{ static final JPush jPush = JPush(); static Future jgInit(AppEnvironment env) async{ jPush.setup( // 极光推送 正式环境appkey需要再申请 appKey: env == AppEnvironment.product ? '2f42e3db4d0083b0bc5a3f6c' : '2f42e3db4d0083b0bc5a3f6c', channel: 'developer-default', production: env == AppEnvironment.product ? true : false, debug: env == AppEnvironment.develop ? true : false ); jPush.addEventHandler( // 接收通知回调方法。 onReceiveNotification: (Map message) async { print("flutter onReceiveNotification: $message"); }, // 点击通知回调方法。 onOpenNotification: (Map message) async { print("flutter onOpenNotification: $message"); }, // 接收自定义消息回调方法。 onReceiveMessage: (Map message) async { print("flutter onReceiveMessage: $message"); }, ); } }