Merge pull request #74 from raoxudong/dev

v0.2.0
master
raoxudong 5 years ago committed by GitHub
commit 01b5f7c1f0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -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/ 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/ 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/ 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 ## 0.1.0
+ 修复:调用 sendLocalNotification 接口 crash 问题; + 修复:调用 sendLocalNotification 接口 crash 问题;
+ 修复iOS 启动 APP 角标自动消失问题; + 修复iOS 启动 APP 角标自动消失问题;

@ -7,7 +7,14 @@
```yaml ```yaml
dependencies: 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> </intent-filter>
</service> </service>
</application> </application>
<uses-permission android:name="com.huawei.android.launcher.permission.CHANGE_BADGE "/>
</manifest> </manifest>

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

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

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

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

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

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

Loading…
Cancel
Save