Skip to content

Commit

Permalink
feat: 修复代码冲突
Browse files Browse the repository at this point in the history
  • Loading branch information
wangyun137 committed Apr 18, 2023
2 parents 7bff29c + 6084382 commit f437b48
Show file tree
Hide file tree
Showing 8 changed files with 51 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,5 @@ example/android/.idea/
example/android/.gradle/
example/build/
.idea/
.vscode/
.vscode/

8 changes: 7 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,14 @@

## 0.0.5


* 修复Android创建Channel时desc字段key值不一致问题

## 0.0.6

* android代码增加保护机制
* android代码增加保护机制

## 0.0.7

* ios初始化时增加网络判断

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1001,6 +1001,7 @@ _aliyunPush.syncIOSBadgeNum(badgeNum).then((result) {
});
```


### getApnsDeviceToken

`Future<String> getApnsDeviceToken() async`
Expand Down
2 changes: 1 addition & 1 deletion android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ android {
}

defaultConfig {
minSdkVersion 16
minSdkVersion 19
}
}

Expand Down
30 changes: 30 additions & 0 deletions android/src/main/java/com/aliyun/ams/push/AliyunPushPlugin.java
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,7 @@ public void onMethodCall(@NonNull MethodCall call, @NonNull Result result) {
} else if ("createGroup".equals(methodName)) {
createGroup(call, result);
} else if ("isNotificationEnabled".equals(methodName)) {

try {
isNotificationEnabled(call, result);
} catch (Exception e) {
Expand Down Expand Up @@ -207,18 +208,21 @@ private void initThirdPush(Result result) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}

private void closePushLog(Result result) {
CloudPushService service = PushServiceFactory.getCloudPushService();
service.setLogLevel(CloudPushService.LOG_OFF);
HashMap<String, String> map = new HashMap<>();
map.put(CODE_KEY, CODE_SUCCESS);

try {
result.success(map);
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}

private void getDeviceId(Result result) {
Expand All @@ -229,6 +233,7 @@ private void getDeviceId(Result result) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}

private void setLogLevel(MethodCall call, Result result) {
Expand All @@ -247,6 +252,7 @@ private void setLogLevel(MethodCall call, Result result) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}

private void bindAccount(MethodCall call, Result result) {
Expand All @@ -260,6 +266,7 @@ private void bindAccount(MethodCall call, Result result) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

} else {
final CloudPushService pushService = PushServiceFactory.getCloudPushService();
pushService.bindAccount(account, new CommonCallback() {
Expand All @@ -282,6 +289,7 @@ public void onFailed(String errorCode, String errorMsg) {
} catch (Exception e){
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}
});
}
Expand All @@ -299,6 +307,7 @@ public void onSuccess(String response) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}

@Override
Expand All @@ -310,6 +319,7 @@ public void onFailed(String errorCode, String errorMsg) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}
});
}
Expand All @@ -325,6 +335,7 @@ private void addAlias(MethodCall call, Result result) {
} catch (Exception e){
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

} else {
final CloudPushService pushService = PushServiceFactory.getCloudPushService();
pushService.addAlias(alias, new CommonCallback() {
Expand All @@ -336,6 +347,7 @@ public void onSuccess(String response) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}

@Override
Expand All @@ -347,6 +359,7 @@ public void onFailed(String errorCode, String errorMsg) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}
});
}
Expand All @@ -363,6 +376,7 @@ private void removeAlias(MethodCall call, Result result) {
} catch (Exception e){
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

} else {
final CloudPushService pushService = PushServiceFactory.getCloudPushService();
pushService.removeAlias(alias, new CommonCallback() {
Expand All @@ -385,6 +399,7 @@ public void onFailed(String errorCode, String errorMsg) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}
});
}
Expand Down Expand Up @@ -429,6 +444,7 @@ private void bindTag(MethodCall call, Result result) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

} else {
Integer target = call.argument("target");
if (target == null) {
Expand Down Expand Up @@ -475,6 +491,7 @@ private void unbindTag(MethodCall call, Result result) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

} else {
Integer target = call.argument("target");
if (target == null) {
Expand Down Expand Up @@ -505,6 +522,7 @@ public void onFailed(String errorCode, String errorMsg) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}
});
}
Expand All @@ -528,6 +546,7 @@ public void onSuccess(String response) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}

@Override
Expand All @@ -539,6 +558,7 @@ public void onFailed(String errorCode, String errorMsg) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}
});
}
Expand All @@ -554,6 +574,7 @@ private void bindPhoneNumber(MethodCall call, Result result) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

} else {
final CloudPushService pushService = PushServiceFactory.getCloudPushService();
pushService.bindPhoneNumber(phone, new CommonCallback() {
Expand All @@ -565,6 +586,7 @@ public void onSuccess(String response) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}

@Override
Expand All @@ -576,6 +598,7 @@ public void onFailed(String errorCode, String errorMsg) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}
});
}
Expand All @@ -594,6 +617,7 @@ public void onSuccess(String response) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}

@Override
Expand All @@ -605,6 +629,7 @@ public void onFailed(String errorCode, String errorMsg) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}
});
}
Expand Down Expand Up @@ -635,6 +660,7 @@ private void clearNotifications(Result result) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}

private void createChannel(MethodCall call, Result result) {
Expand Down Expand Up @@ -717,6 +743,7 @@ private void createChannel(MethodCall call, Result result) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

} else {
map.put(CODE_KEY, CODE_NOT_SUPPORT);
map.put(ERROR_MSG_KEY,
Expand All @@ -726,6 +753,7 @@ private void createChannel(MethodCall call, Result result) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}
}

Expand All @@ -750,6 +778,7 @@ private void createGroup(MethodCall call, Result result) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

} else {
map.put(CODE_KEY, CODE_NOT_SUPPORT);
map.put(ERROR_MSG_KEY,
Expand All @@ -759,6 +788,7 @@ private void createGroup(MethodCall call, Result result) {
} catch (Exception e) {
AliyunPushLog.e(TAG, Log.getStackTraceString(e));
}

}
}

Expand Down
14 changes: 7 additions & 7 deletions ios/Classes/AliyunPushPlugin.h
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
#import <Flutter/Flutter.h>

static NSString* const KEY_CODE = @"code";
static NSString* const KEY_ERROR_MSG = @"errorMsg";
static NSString *const KEY_CODE = @"code";
static NSString *const KEY_ERROR_MSG = @"errorMsg";

static NSString* const CODE_SUCCESS = @"10000";
static NSString* const CODE_PARAMS_ILLEGAL = @"10001";
static NSString* const CODE_FAILED = @"10002";
static NSString* const CODE_NO_NET = @"10003";
static NSString *const CODE_SUCCESS = @"10000";
static NSString *const CODE_PARAMS_ILLEGAL = @"10001";
static NSString *const CODE_FAILED = @"10002";

static NSString *const CODE_NO_NET = @"10003";

@interface AliyunPushPlugin : NSObject <FlutterPlugin>
@property FlutterMethodChannel *channel;
@end

2 changes: 2 additions & 0 deletions ios/Classes/AliyunPushPlugin.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#import <UserNotifications/UserNotifications.h>
#import <AlicloudUtils/AlicloudUtils.h>


@interface AliyunPushLog : NSObject

+ (void)enableLog;
Expand Down Expand Up @@ -315,6 +316,7 @@ - (void) initPushSdk:(FlutterMethodCall*)call result:(FlutterResult)result {
return;
}


//APNS注册,获取deviceToken并上报
[self registerAPNS];

Expand Down
2 changes: 1 addition & 1 deletion pubspec.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: aliyun_push
description: Aliyun Push Flutter plugin.
version: 0.0.6
version: 0.0.7
homepage: https://help.aliyun.com/document_detail/434552.html

environment:
Expand Down

0 comments on commit f437b48

Please sign in to comment.