master
raoxudong 5 years ago
parent 507e876e83
commit 49acf24f9a

@ -1,4 +1,4 @@
# Generated by pub on 2019-08-23 15:35:48.440553.
# Generated by pub on 2019-09-25 15:21:45.301321.
analyzer:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/analyzer-0.37.0/lib/
args:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/args-1.5.2/lib/
async:file:///Applications/flutter/.pub-cache/hosted/pub.flutter-io.cn/async-2.3.0/lib/

@ -1,3 +1,6 @@
## 0.2.0
+ 适配最新版本 JPush SDK
+ Android 支持设置角标 badge
## 0.1.0
+ 修复:调用 sendLocalNotification 接口 crash 问题;
+ 修复iOS 启动 APP 角标自动消失问题;

@ -7,7 +7,14 @@
```yaml
dependencies:
jpush_flutter: 0.1.0
jpush_flutter: 0.2.0
//github
dependencies:
jmessage_flutter:
git:
url: git://github.com/jpush/jmessage-flutter-plugin.git
ref: master
```
### 配置

@ -34,4 +34,5 @@
</intent-filter>
</service>
</application>
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE "/>
</manifest>

@ -33,6 +33,7 @@ public class JPushPlugin implements MethodCallHandler {
}
private static String TAG = "| JPUSH | Android | ";
public static JPushPlugin instance;
static List<Map<String, Object>> openNotificationCache = new ArrayList<>();
@ -60,6 +61,7 @@ public class JPushPlugin implements MethodCallHandler {
@Override
public void onMethodCall(MethodCall call, Result result) {
Log.i(TAG,call.method);
if (call.method.equals("getPlatformVersion")) {
result.success("Android " + android.os.Build.VERSION.RELEASE);
} else if (call.method.equals("setup")) {
@ -90,12 +92,17 @@ public class JPushPlugin implements MethodCallHandler {
getRegistrationID(call, result);
} else if (call.method.equals("sendLocalNotification")) {
sendLocalNotification(call, result);
} else {
} else if (call.method.equals("setBadge")) {
setBadge(call, result);
}
else {
result.notImplemented();
}
}
public void setup(MethodCall call, Result result) {
Log.d(TAG,"setup :" + call.arguments);
HashMap<String, Object> map = call.arguments();
boolean debug = (boolean)map.get("debug");
JPushInterface.setDebugMode(debug);
@ -112,6 +119,8 @@ public class JPushPlugin implements MethodCallHandler {
}
public void scheduleCache() {
Log.d(TAG,"scheduleCache:");
if (dartIsReady) {
// try to shedule notifcation cache
for (Map<String, Object> notification: JPushPlugin.openNotificationCache) {
@ -131,6 +140,8 @@ public class JPushPlugin implements MethodCallHandler {
}
public void setTags(MethodCall call, Result result) {
Log.d(TAG,"setTags");
List<String>tagList = call.arguments();
Set<String> tags = new HashSet<>(tagList);
sequence += 1;
@ -139,12 +150,16 @@ public class JPushPlugin implements MethodCallHandler {
}
public void cleanTags(MethodCall call, Result result) {
Log.d(TAG,"cleanTags:");
sequence += 1;
callbackMap.put(sequence, result);
JPushInterface.cleanTags(registrar.context(), sequence);
}
public void addTags(MethodCall call, Result result) {
Log.d(TAG,"addTags: " + call.arguments);
List<String>tagList = call.arguments();
Set<String> tags = new HashSet<>(tagList);
sequence += 1;
@ -153,6 +168,8 @@ public class JPushPlugin implements MethodCallHandler {
}
public void deleteTags(MethodCall call, Result result) {
Log.d(TAG,"deleteTags " + call.arguments);
List<String>tagList = call.arguments();
Set<String> tags = new HashSet<>(tagList);
sequence += 1;
@ -161,12 +178,16 @@ public class JPushPlugin implements MethodCallHandler {
}
public void getAllTags(MethodCall call, Result result) {
Log.d(TAG,"getAllTags ");
sequence += 1;
callbackMap.put(sequence, result);
JPushInterface.getAllTags(registrar.context(), sequence);
}
public void setAlias(MethodCall call, Result result) {
Log.d(TAG,"setAlias: " + call.arguments);
String alias= call.arguments();
sequence += 1;
callbackMap.put(sequence, result);
@ -174,6 +195,8 @@ public class JPushPlugin implements MethodCallHandler {
}
public void deleteAlias(MethodCall call, Result result) {
Log.d(TAG,"deleteAlias:");
String alias= call.arguments();
sequence += 1;
callbackMap.put(sequence, result);
@ -181,22 +204,31 @@ public class JPushPlugin implements MethodCallHandler {
}
public void stopPush(MethodCall call, Result result) {
Log.d(TAG,"stopPush:");
JPushInterface.stopPush(registrar.context());
}
public void resumePush(MethodCall call, Result result) {
Log.d(TAG,"resumePush:");
JPushInterface.resumePush(registrar.context());
}
public void clearAllNotifications(MethodCall call, Result result) {
Log.d(TAG,"clearAllNotifications: ");
JPushInterface.clearAllNotifications(registrar.context());
}
public void getLaunchAppNotification(MethodCall call, Result result) {
Log.d(TAG,"");
}
public void getRegistrationID(MethodCall call, Result result) {
Log.d(TAG,"getRegistrationID: ");
String rid = JPushInterface.getRegistrationID(registrar.context());
if (rid == null || rid.isEmpty()) {
@ -208,6 +240,8 @@ public class JPushPlugin implements MethodCallHandler {
public void sendLocalNotification(MethodCall call, Result result) {
Log.d(TAG,"sendLocalNotification: " + call.arguments);
try {
HashMap<String, Object> map = call.arguments();
@ -232,6 +266,17 @@ public class JPushPlugin implements MethodCallHandler {
}
}
public void setBadge(MethodCall call, Result result) {
Log.d(TAG,"setBadge: " + call.arguments);
HashMap<String, Object> map = call.arguments();
Object numObject = map.get("badge");
if (numObject != null) {
int num = (int)numObject;
JPushInterface.setBadgeNumber(registrar.context(),num);
result.success(true);
}
}
/**
* ,,广
@ -248,6 +293,7 @@ public class JPushPlugin implements MethodCallHandler {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
if (action.equals(JPushInterface.ACTION_REGISTRATION_ID)) {
String rId = intent.getStringExtra(JPushInterface.EXTRA_REGISTRATION_ID);
Log.d("JPushPlugin","on get registration");
@ -264,12 +310,16 @@ public class JPushPlugin implements MethodCallHandler {
}
private void handlingMessageReceive(Intent intent) {
Log.d(TAG,"handlingMessageReceive " + intent.getAction());
String msg = intent.getStringExtra(JPushInterface.EXTRA_MESSAGE);
Map<String, Object> extras = getNotificationExtras(intent);
JPushPlugin.transmitMessageReceive(msg, extras);
}
private void handlingNotificationOpen(Context context, Intent intent) {
Log.d(TAG,"handlingNotificationOpen " + intent.getAction());
String title = intent.getStringExtra(JPushInterface.EXTRA_NOTIFICATION_TITLE);
String alert = intent.getStringExtra(JPushInterface.EXTRA_ALERT);
Map<String, Object> extras = getNotificationExtras(intent);
@ -284,6 +334,8 @@ public class JPushPlugin implements MethodCallHandler {
}
private void handlingNotificationReceive(Context context, Intent intent) {
Log.d(TAG,"handlingNotificationReceive " + intent.getAction());
String title = intent.getStringExtra(JPushInterface.EXTRA_NOTIFICATION_TITLE);
String alert = intent.getStringExtra(JPushInterface.EXTRA_ALERT);
Map<String, Object> extras = getNotificationExtras(intent);
@ -291,6 +343,8 @@ public class JPushPlugin implements MethodCallHandler {
}
private Map<String, Object> getNotificationExtras(Intent intent) {
Log.d(TAG,"");
Map<String, Object> extrasMap = new HashMap<String, Object>();
for (String key : intent.getExtras().keySet()) {
if (!IGNORED_EXTRAS_KEYS.contains(key)) {
@ -307,6 +361,8 @@ public class JPushPlugin implements MethodCallHandler {
static void transmitMessageReceive(String message, Map<String, Object> extras) {
Log.d(TAG,"transmitMessageReceive " + "message=" + message + "extras=" + extras);
if (instance == null) {
return;
}
@ -318,6 +374,8 @@ public class JPushPlugin implements MethodCallHandler {
}
static void transmitNotificationOpen(String title, String alert, Map<String, Object> extras) {
Log.d(TAG,"transmitNotificationOpen " + "title=" + title + "alert=" + alert + "extras=" + extras);
Map<String, Object> notification= new HashMap<>();
notification.put("title", title);
notification.put("alert", alert);
@ -338,6 +396,8 @@ public class JPushPlugin implements MethodCallHandler {
}
static void transmitNotificationReceive(String title, String alert, Map<String, Object> extras) {
Log.d(TAG,"transmitNotificationReceive " + "title=" + title + "alert=" + alert + "extras=" + extras);
if (instance == null) {
return;
}
@ -350,6 +410,8 @@ public class JPushPlugin implements MethodCallHandler {
}
static void transmitReceiveRegistrationId(String rId) {
Log.d(TAG,"transmitReceiveRegistrationId " + rId);
if (instance == null) {
return;
}

@ -8,7 +8,6 @@
/* Begin PBXBuildFile section */
1498D2341E8E89220040F4C2 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
342565195A7B02408C258C63 /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = E8558CD656C3CFECC78ECB83 /* libPods-Runner.a */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
@ -41,7 +40,7 @@
/* Begin PBXFileReference section */
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
243DB7546D048251A9867C1C /* Pods-Runner.debug.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.debug.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.debug.xcconfig"; sourceTree = "<group>"; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
625494FA213F7D30005E4423 /* Runner.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = Runner.entitlements; sourceTree = "<group>"; };
@ -57,6 +56,7 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
C3EB3B32DF8D367805D86460 /* Pods-Runner.release.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.release.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.release.xcconfig"; sourceTree = "<group>"; };
E8558CD656C3CFECC78ECB83 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */
@ -85,7 +85,6 @@
9740EEB11CF90186004384FC /* Flutter */ = {
isa = PBXGroup;
children = (
2D5378251FAA1A9400D5DBA9 /* flutter_assets */,
3B80C3931E831B6300D905FE /* App.framework */,
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */,
9740EEBA1CF902C7004384FC /* Flutter.framework */,
@ -143,6 +142,8 @@
AB735DD26662031199114838 /* Pods */ = {
isa = PBXGroup;
children = (
243DB7546D048251A9867C1C /* Pods-Runner.debug.xcconfig */,
C3EB3B32DF8D367805D86460 /* Pods-Runner.release.xcconfig */,
);
name = Pods;
sourceTree = "<group>";
@ -183,7 +184,7 @@
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = RL64Y54S9V;
ProvisioningStyle = Manual;
SystemCapabilities = {
com.apple.ApplePay = {
enabled = 0;
@ -203,6 +204,7 @@
developmentRegion = English;
hasScannedForEncodings = 0;
knownRegions = (
English,
en,
Base,
);
@ -225,7 +227,6 @@
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */,
9740EEB41CF90195004384FC /* Debug.xcconfig in Resources */,
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */,
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */,
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */,
);
runOnlyForDeploymentPostprocessing = 0;
@ -239,16 +240,13 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
showEnvVarsInLog = 0;
};
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
@ -440,8 +438,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = RL64Y54S9V;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -453,8 +453,9 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.huminios.jpushTest;
PRODUCT_BUNDLE_IDENTIFIER = com.jpush.test;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
VERSIONING_SYSTEM = "apple-generic";
};
name = Debug;
@ -465,8 +466,10 @@
buildSettings = {
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
CODE_SIGN_ENTITLEMENTS = Runner/Runner.entitlements;
CODE_SIGN_IDENTITY = "iPhone Developer";
CODE_SIGN_STYLE = Manual;
CURRENT_PROJECT_VERSION = "$(FLUTTER_BUILD_NUMBER)";
DEVELOPMENT_TEAM = RL64Y54S9V;
DEVELOPMENT_TEAM = "";
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
@ -478,8 +481,9 @@
"$(inherited)",
"$(PROJECT_DIR)/Flutter",
);
PRODUCT_BUNDLE_IDENTIFIER = com.example.huminios.jpushTest;
PRODUCT_BUNDLE_IDENTIFIER = com.jpush.test;
PRODUCT_NAME = "$(TARGET_NAME)";
PROVISIONING_PROFILE_SPECIFIER = "";
VERSIONING_SYSTEM = "apple-generic";
};
name = Release;

@ -136,7 +136,7 @@ packages:
path: ".."
relative: true
source: path
version: "0.1.0"
version: "0.2.0"
js:
dependency: transitive
description:

@ -5,6 +5,8 @@
#import <JPush/JPUSHService.h>
#define JPLog(fmt, ...) NSLog((@"| JPUSH | iOS | " fmt), ##__VA_ARGS__)
@interface NSError (FlutterError)
@property(readonly, nonatomic) FlutterError *flutterError;
@end
@ -111,6 +113,8 @@ static NSMutableArray<FlutterResult>* getRidResults;
}
- (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"handleMethodCall:%@",call.method);
if ([@"getPlatformVersion" isEqualToString:call.method]) {
result([@"iOS " stringByAppendingString:[[UIDevice currentDevice] systemVersion]]);
} else if([@"setup" isEqualToString:call.method]) {
@ -153,6 +157,7 @@ static NSMutableArray<FlutterResult>* getRidResults;
- (void)setup:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"setup:");
NSDictionary *arguments = call.arguments;
NSNumber *debug = arguments[@"debug"];
if ([debug boolValue]) {
@ -168,6 +173,7 @@ static NSMutableArray<FlutterResult>* getRidResults;
}
- (void)applyPushAuthority:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"applyPushAuthority:%@",call.arguments);
notificationTypes = 0;
NSDictionary *arguments = call.arguments;
if ([arguments[@"sound"] boolValue]) {
@ -185,6 +191,7 @@ static NSMutableArray<FlutterResult>* getRidResults;
}
- (void)setTags:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"setTags:%@",call.arguments);
NSSet *tagSet;
if (call.arguments != NULL) {
@ -202,6 +209,7 @@ static NSMutableArray<FlutterResult>* getRidResults;
}
- (void)cleanTags:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"cleanTags:");
[JPUSHService cleanTags:^(NSInteger iResCode, NSSet *iTags, NSInteger seq) {
if (iResCode == 0) {
result(@{@"tags": iTags ? [iTags allObjects] : @[]});
@ -213,6 +221,7 @@ static NSMutableArray<FlutterResult>* getRidResults;
}
- (void)addTags:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"addTags:%@",call.arguments);
NSSet *tagSet;
if (call.arguments != NULL) {
@ -230,6 +239,7 @@ static NSMutableArray<FlutterResult>* getRidResults;
}
- (void)deleteTags:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"deleteTags:%@",call.arguments);
NSSet *tagSet;
if (call.arguments != NULL) {
@ -247,6 +257,7 @@ static NSMutableArray<FlutterResult>* getRidResults;
}
- (void)getAllTags:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"getAllTags:");
[JPUSHService getAllTags:^(NSInteger iResCode, NSSet *iTags, NSInteger seq) {
if (iResCode == 0) {
result(@{@"tags": iTags ? [iTags allObjects] : @[]});
@ -258,6 +269,7 @@ static NSMutableArray<FlutterResult>* getRidResults;
}
- (void)setAlias:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"setAlias:%@",call.arguments);
NSString *alias = call.arguments;
[JPUSHService setAlias:alias completion:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
if (iResCode == 0) {
@ -270,6 +282,7 @@ static NSMutableArray<FlutterResult>* getRidResults;
}
- (void)deleteAlias:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"deleteAlias:%@",call.arguments);
[JPUSHService deleteAlias:^(NSInteger iResCode, NSString *iAlias, NSInteger seq) {
if (iResCode == 0) {
result(@{@"alias": iAlias ?: @""});
@ -281,24 +294,32 @@ static NSMutableArray<FlutterResult>* getRidResults;
}
- (void)setBadge:(FlutterMethodCall*)call result:(FlutterResult)result {
NSNumber *badge = call.arguments;
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: badge.integerValue];
[JPUSHService setBadge: badge.integerValue > 0 ? badge.integerValue: 0];
JPLog(@"setBadge:%@",call.arguments);
NSInteger badge = [call.arguments[@"badge"] integerValue];
if (badge < 0) {
badge = 0;
}
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: badge];
[JPUSHService setBadge: badge];
}
- (void)stopPush:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"stopPush:");
[[UIApplication sharedApplication] unregisterForRemoteNotifications];
}
- (void)clearAllNotifications:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"clearAllNotifications:");
[[UIApplication sharedApplication] setApplicationIconBadgeNumber: 0];
}
- (void)getLaunchAppNotification:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"getLaunchAppNotification");
result(_launchNotification == nil ? @{}: _launchNotification);
}
- (void)getRegistrationID:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"getRegistrationID:");
#if TARGET_IPHONE_SIMULATOR//模拟器
NSLog(@"simulator can not get registrationid");
result(@"");
@ -320,6 +341,7 @@ static NSMutableArray<FlutterResult>* getRidResults;
}
- (void)sendLocalNotification:(FlutterMethodCall*)call result:(FlutterResult)result {
JPLog(@"sendLocalNotification:%@",call.arguments);
JPushNotificationContent *content = [[JPushNotificationContent alloc] init];
NSDictionary *params = call.arguments;
if (params[@"title"]) {

@ -7,6 +7,7 @@ import 'package:platform/platform.dart';
typedef Future<dynamic> EventHandler(Map<String, dynamic> event);
class JPush {
final String flutter_log = "| JPUSH | Flutter | ";
factory JPush() => _instance;
final MethodChannel _channel;
@ -31,6 +32,8 @@ class JPush {
String channel = '',
bool debug = false,
}) {
print(flutter_log + "setup:");
_channel.invokeMethod('setup', { 'appKey': appKey, 'channel': channel, 'production': production, 'debug': debug});
}
///
@ -41,6 +44,8 @@ class JPush {
EventHandler onOpenNotification,
EventHandler onReceiveMessage,
}) {
print(flutter_log + "addEventHandler:");
_onReceiveNotification = onReceiveNotification;
_onOpenNotification = onOpenNotification;
_onReceiveMessage = onReceiveMessage;
@ -48,6 +53,8 @@ class JPush {
}
Future<Null> _handleMethod(MethodCall call) async {
print(flutter_log + "_handleMethod:");
switch (call.method) {
case "onReceiveNotification":
return _onReceiveNotification(call.arguments.cast<String, dynamic>());
@ -64,6 +71,7 @@ class JPush {
///
///
void applyPushAuthority([NotificationSettingsIOS iosSettings = const NotificationSettingsIOS()]) {
print(flutter_log + "applyPushAuthority:");
if (!_platform.isIOS) {
return;
@ -80,6 +88,8 @@ class JPush {
/// @param {Function} fail = ({"errorCode":int}) => { }
///
Future<Map<dynamic, dynamic>> setTags(List<String> tags) async {
print(flutter_log + "setTags:");
final Map<dynamic, dynamic> result = await _channel.invokeMethod('setTags', tags);
return result;
}
@ -91,6 +101,8 @@ class JPush {
/// @param {Function} fail = ({"errorCode":int}) => { }
///
Future<Map<dynamic, dynamic>> cleanTags() async {
print(flutter_log + "cleanTags:");
final Map<dynamic, dynamic> result = await _channel.invokeMethod('cleanTags');
return result;
}
@ -104,6 +116,8 @@ class JPush {
///
Future<Map<dynamic, dynamic>> addTags(List<String> tags) async {
print(flutter_log + "addTags:");
final Map<dynamic, dynamic> result = await _channel.invokeMethod('addTags', tags);
return result;
}
@ -116,6 +130,8 @@ class JPush {
/// @param {Function} fail = ({"errorCode":int}) => { }
///
Future<Map<dynamic, dynamic>> deleteTags(List<String> tags) async {
print(flutter_log + "deleteTags:");
final Map<dynamic, dynamic> result = await _channel.invokeMethod('deleteTags', tags);
return result;
}
@ -127,6 +143,8 @@ class JPush {
/// @param {Function} fail = ({"errorCode":int}) => { }
///
Future<Map<dynamic, dynamic>> getAllTags() async {
print(flutter_log + "getAllTags:");
final Map<dynamic, dynamic> result = await _channel.invokeMethod('getAllTags');
return result;
}
@ -140,6 +158,8 @@ class JPush {
/// @param {Function} fail = ({"errorCode":int}) => { }
///
Future<Map<dynamic, dynamic>> setAlias(String alias) async {
print(flutter_log + "setAlias:");
final Map<dynamic, dynamic> result = await _channel.invokeMethod('setAlias', alias);
return result;
}
@ -151,24 +171,31 @@ class JPush {
/// @param {Function} fail = ({"errorCode":int}) => { }
///
Future<Map<dynamic, dynamic>> deleteAlias() async {
print(flutter_log + "deleteAlias:");
final Map<dynamic, dynamic> result = await _channel.invokeMethod('deleteAlias');
return result;
}
///
/// iOS Only
/// Badge
///
/// @param {Int} badge
///
/// Android
///
Future setBadge(int badge) async {
await _channel.invokeMethod('setBadge', badge);
print(flutter_log + "setBadge:");
await _channel.invokeMethod('setBadge', {"badge":badge});
}
///
/// resumePush
///
Future stopPush() async {
print(flutter_log + "stopPush:");
await _channel.invokeMethod('stopPush');
}
@ -176,6 +203,8 @@ class JPush {
///
///
Future resumePush() async {
print(flutter_log + "resumePush:");
await _channel.invokeMethod('resumePush');
}
@ -183,6 +212,8 @@ class JPush {
///
///
Future clearAllNotifications() async {
print(flutter_log + "clearAllNotifications:");
await _channel.invokeMethod('clearAllNotifications');
}
@ -194,6 +225,8 @@ class JPush {
/// @param {Function} callback = (Object) => {}
///
Future<Map<dynamic, dynamic>> getLaunchAppNotification() async {
print(flutter_log + "getLaunchAppNotification:");
final Map<dynamic, dynamic> result = await _channel.invokeMethod('getLaunchAppNotification');
return result;
}
@ -204,6 +237,8 @@ class JPush {
/// @param {Function} callback = (String) => {}
///
Future<String> getRegistrationID() async {
print(flutter_log + "getRegistrationID:");
final String rid = await _channel.invokeMethod('getRegistrationID');
return rid;
}
@ -213,10 +248,13 @@ class JPush {
/// @param {Notification} notification
///
Future<String> sendLocalNotification(LocalNotification notification) async {
print(flutter_log + "sendLocalNotification:");
await _channel.invokeMethod('sendLocalNotification', notification.toMap());
return notification.toMap().toString();
}
}
class NotificationSettingsIOS {

@ -1,6 +1,6 @@
name: jpush_flutter
description: Offically supported JPush Flutter plugin.
version: 0.1.0
version: 0.2.0
author: huminios <h380108184@gmail.com>
homepage: https://www.jiguang.cn

Loading…
Cancel
Save