Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
flutter_jdsdk
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
李增强
flutter_jdsdk
Commits
3c95241b
Commit
3c95241b
authored
Jun 02, 2021
by
汪林玲
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
整合iOS到flutter 插件中
parent
0dcdfcf6
Changes
17
Hide whitespace changes
Inline
Side-by-side
Showing
17 changed files
with
207 additions
and
82 deletions
+207
-82
android/src/main/java/com/jd/jdsdk/JdsdkPlugin.java
android/src/main/java/com/jd/jdsdk/JdsdkPlugin.java
+1
-3
example/ios/Flutter/.last_build_id
example/ios/Flutter/.last_build_id
+1
-1
example/ios/Podfile.lock
example/ios/Podfile.lock
+5
-5
example/ios/Runner.xcodeproj/project.pbxproj
example/ios/Runner.xcodeproj/project.pbxproj
+7
-7
example/lib/main.dart
example/lib/main.dart
+11
-38
example/pubspec.lock
example/pubspec.lock
+1
-1
example/pubspec.yaml
example/pubspec.yaml
+1
-1
ios/Classes/JdsdkPlugin.m
ios/Classes/JdsdkPlugin.m
+22
-9
ios/Framework/JDSDK.framework/Headers/JDKeplerSDK.h
ios/Framework/JDSDK.framework/Headers/JDKeplerSDK.h
+20
-0
ios/Framework/JDSDK.framework/Headers/KeplerApiManager.h
ios/Framework/JDSDK.framework/Headers/KeplerApiManager.h
+111
-0
ios/Framework/JDSDK.framework/Info.plist
ios/Framework/JDSDK.framework/Info.plist
+0
-0
ios/Framework/JDSDK.framework/JDSDK
ios/Framework/JDSDK.framework/JDSDK
+0
-0
ios/Framework/JDSDK.framework/Modules/module.modulemap
ios/Framework/JDSDK.framework/Modules/module.modulemap
+6
-0
ios/jd_sdk.podspec
ios/jd_sdk.podspec
+11
-4
lib/jdsdk.dart
lib/jdsdk.dart
+9
-7
pubspec.yaml
pubspec.yaml
+1
-1
test/jdsdk_test.dart
test/jdsdk_test.dart
+0
-5
No files found.
android/src/main/java/com/jd/jdsdk/JdsdkPlugin.java
View file @
3c95241b
...
...
@@ -29,9 +29,7 @@ public class JdsdkPlugin implements FlutterPlugin, MethodCallHandler, ActivityAw
@Override
public
void
onMethodCall
(
MethodCall
call
,
Result
result
)
{
if
(
call
.
method
.
equals
(
"getPlatformVersion"
))
{
result
.
success
(
"Android "
+
android
.
os
.
Build
.
VERSION
.
RELEASE
);
}
else
if
(
call
.
method
.
equals
(
"init"
))
{
if
(
call
.
method
.
equals
(
"init"
))
{
mJDHelper
.
initKepler
(
call
,
result
);
}
else
if
(
call
.
method
.
equals
(
"openUrl"
))
{
Log
.
d
(
"flutter-test"
,
"openUrl"
);
...
...
example/ios/Flutter/.last_build_id
View file @
3c95241b
4ee6262d6df4eae39aef50da3587f661
\ No newline at end of file
9b225167b750ff91e229b9ed7eda1696
\ No newline at end of file
example/ios/Podfile.lock
View file @
3c95241b
PODS:
- Flutter (1.0.0)
- jd
sdk (0.0.1
):
- jd
_sdk (1.0.0
):
- Flutter
DEPENDENCIES:
- Flutter (from `Flutter`)
- jd
sdk (from `.symlinks/plugins/jd
sdk/ios`)
- jd
_sdk (from `.symlinks/plugins/jd_
sdk/ios`)
EXTERNAL SOURCES:
Flutter:
:path: Flutter
jdsdk:
:path: ".symlinks/plugins/jdsdk/ios"
jd
_
sdk:
:path: ".symlinks/plugins/jd
_
sdk/ios"
SPEC CHECKSUMS:
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
jd
sdk: 33a8f56cd92bebbe1fece516e092aa22bd0e6a8b
jd
_sdk: 795291e67471d1924fd27717221a445dd4ffec09
PODFILE CHECKSUM: 1e5bdb5d3f5df2396887ecffd613804a61b33078
...
...
example/ios/Runner.xcodeproj/project.pbxproj
View file @
3c95241b
...
...
@@ -198,7 +198,7 @@
TargetAttributes
=
{
97C146ED1CF9000F007C117D
=
{
CreatedOnToolsVersion
=
7.3.1
;
DevelopmentTeam
=
ZMCJ78285X
;
DevelopmentTeam
=
4R6KK56452
;
};
};
};
...
...
@@ -392,7 +392,7 @@
buildSettings
=
{
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
CURRENT_PROJECT_VERSION
=
"$(FLUTTER_BUILD_NUMBER)"
;
DEVELOPMENT_TEAM
=
ZMCJ78285X
;
DEVELOPMENT_TEAM
=
4R6KK56452
;
ENABLE_BITCODE
=
NO
;
FRAMEWORK_SEARCH_PATHS
=
(
"$(inherited)"
,
...
...
@@ -404,7 +404,7 @@
"$(inherited)"
,
"$(PROJECT_DIR)/Flutter"
,
);
PRODUCT_BUNDLE_IDENTIFIER
=
com.youliapp
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.youliapp
.test
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
VERSIONING_SYSTEM
=
"apple-generic"
;
};
...
...
@@ -521,7 +521,7 @@
buildSettings
=
{
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
CURRENT_PROJECT_VERSION
=
"$(FLUTTER_BUILD_NUMBER)"
;
DEVELOPMENT_TEAM
=
ZMCJ78285X
;
DEVELOPMENT_TEAM
=
4R6KK56452
;
ENABLE_BITCODE
=
NO
;
FRAMEWORK_SEARCH_PATHS
=
(
"$(inherited)"
,
...
...
@@ -533,7 +533,7 @@
"$(inherited)"
,
"$(PROJECT_DIR)/Flutter"
,
);
PRODUCT_BUNDLE_IDENTIFIER
=
com.youliapp
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.youliapp
.test
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
VERSIONING_SYSTEM
=
"apple-generic"
;
};
...
...
@@ -545,7 +545,7 @@
buildSettings
=
{
ASSETCATALOG_COMPILER_APPICON_NAME
=
AppIcon
;
CURRENT_PROJECT_VERSION
=
"$(FLUTTER_BUILD_NUMBER)"
;
DEVELOPMENT_TEAM
=
ZMCJ78285X
;
DEVELOPMENT_TEAM
=
4R6KK56452
;
ENABLE_BITCODE
=
NO
;
FRAMEWORK_SEARCH_PATHS
=
(
"$(inherited)"
,
...
...
@@ -557,7 +557,7 @@
"$(inherited)"
,
"$(PROJECT_DIR)/Flutter"
,
);
PRODUCT_BUNDLE_IDENTIFIER
=
com.youliapp
;
PRODUCT_BUNDLE_IDENTIFIER
=
com.youliapp
.test
;
PRODUCT_NAME
=
"$(TARGET_NAME)"
;
VERSIONING_SYSTEM
=
"apple-generic"
;
};
...
...
example/lib/main.dart
View file @
3c95241b
...
...
@@ -2,7 +2,7 @@ import 'package:flutter/material.dart';
import
'dart:async'
;
import
'package:flutter/services.dart'
;
import
'package:jdsdk/jdsdk.dart'
;
import
'package:jd
_
sdk/jdsdk.dart'
;
void
main
(
)
=>
runApp
(
MyApp
());
...
...
@@ -12,32 +12,9 @@ class MyApp extends StatefulWidget {
}
class
_MyAppState
extends
State
<
MyApp
>
{
String
_platformVersion
=
'Unknown'
;
@override
void
initState
()
{
super
.
initState
();
initPlatformState
();
}
// Platform messages are asynchronous, so we initialize in an async method.
Future
<
void
>
initPlatformState
()
async
{
String
platformVersion
;
// Platform messages may fail, so we use a try/catch PlatformException.
try
{
platformVersion
=
await
Jdsdk
.
platformVersion
;
}
on
PlatformException
{
platformVersion
=
'Failed to get platform version.'
;
}
// If the widget was removed from the tree while the asynchronous platform
// message was in flight, we want to discard the reply rather than calling
// setState to update our non-existent appearance.
if
(!
mounted
)
return
;
setState
(()
{
_platformVersion
=
platformVersion
;
});
}
@override
...
...
@@ -50,33 +27,29 @@ class _MyAppState extends State<MyApp> {
body:
Column
(
children:
<
Widget
>[
InkWell
(
onTap:
()
async
{
//android
var
result
=
await
Jdsdk
.
init
(
appKey:
''
,
appSecret:
''
);
onTap:
()
async
{
//android
var
result
=
await
Jdsdk
.
init
(
appKey:
''
,
appSecret:
''
);
print
(
result
);
},
child:
Center
(
child:
Text
(
'测试初迟化'
),
child:
Text
(
'测试初迟化'
),
),
),
SizedBox
(
height:
100
,
),
InkWell
(
onTap:
()
async
{
var
result
=
await
Jdsdk
.
openUrl
(
url:
'https://item.m.jd.com/product/100009963992.html?wxa_abtest=o&utm_user=plusmember&ad_od=share&utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=CopyURL'
);
onTap:
()
async
{
var
result
=
await
Jdsdk
.
openUrl
(
url:
'https://item.m.jd.com/product/100009963992.html?wxa_abtest=o&utm_user=plusmember&ad_od=share&utm_source=androidapp&utm_medium=appshare&utm_campaign=t_335139774&utm_term=CopyURL'
);
print
(
result
);
},
},
child:
Center
(
child:
Text
(
'测试打开京东'
),
child:
Text
(
'测试打开京东'
),
),
),
],
),
),
...
...
example/pubspec.lock
View file @
3c95241b
...
...
@@ -67,7 +67,7 @@ packages:
description: flutter
source: sdk
version: "0.0.0"
jdsdk:
jd
_
sdk:
dependency: "direct dev"
description:
path: ".."
...
...
example/pubspec.yaml
View file @
3c95241b
...
...
@@ -17,7 +17,7 @@ dev_dependencies:
flutter_test
:
sdk
:
flutter
jdsdk
:
jd
_
sdk
:
path
:
../
# For information on the generic Dart part of this file, see the
...
...
ios/Classes/JdsdkPlugin.m
View file @
3c95241b
#import "JdsdkPlugin.h"
#import "JDSDK/JDKeplerSDK.h"
@interface
JdsdkPlugin
()
@end
@implementation
JdsdkPlugin
+
(
void
)
registerWithRegistrar
:(
NSObject
<
FlutterPluginRegistrar
>*
)
registrar
{
NSLog
(
@"registerWithRegistrar"
);
FlutterMethodChannel
*
channel
=
[
FlutterMethodChannel
methodChannelWithName:
@"jdsdk"
binaryMessenger:
[
registrar
messenger
]];
FlutterMethodChannel
*
channel
=
[
FlutterMethodChannel
methodChannelWithName
:
@"jdsdk"
binaryMessenger
:[
registrar
messenger
]];
JdsdkPlugin
*
instance
=
[[
JdsdkPlugin
alloc
]
init
];
//将 JdsdkPlugin 的无参 init 函数调整为 initWithRegistrar
// JdsdkPlugin* instance = [[JdsdkPlugin alloc] initWithRegistrar:registrar];
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
}
-
(
void
)
handleMethodCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
if
([
@"getPlatformVersion"
isEqualToString
:
call
.
method
])
{
result
([
@"iOS "
stringByAppendingString
:[[
UIDevice
currentDevice
]
systemVersion
]]);
if
([
@"init"
isEqualToString
:
call
.
method
])
{
NSString
*
appKey
=
call
.
arguments
[
@"appKey"
];
NSString
*
appSecret
=
call
.
arguments
[
@"appSecret"
];
[[
KeplerApiManager
sharedKPService
]
asyncInitSdk
:
appKey
secretKey
:
appSecret
sucessCallback
:^
(){
result
(
@"{status:1}"
);
}
failedCallback
:^
(
NSError
*
error
){
result
(
@"{status:0}"
);
}];
}
else
if
([
@"openUrl"
isEqualToString
:
call
.
method
]){
NSString
*
url
=
call
.
arguments
[
@"url"
];
//判断是否安装京东app
if
([[
UIApplication
sharedApplication
]
canOpenURL
:[
NSURL
URLWithString
:[
NSString
stringWithFormat
:
@"openapp.jdmobile://"
]]])
{
[[
KeplerApiManager
sharedKPService
]
openKeplerPageWithURL
:
url
userInfo
:
nil
successCallback
:^
{
result
(
@"{status:1}"
);
}
failedCallback
:^
(
NSInteger
code
,
NSString
*
_Nonnull
url
)
{
result
(
@"{status:0}"
);
}];
}
else
{
result
(
@"{status:0}"
);
}
}
else
{
result
(
FlutterMethodNotImplemented
);
}
...
...
ios/Framework/JDSDK.framework/Headers/JDKeplerSDK.h
0 → 100755
View file @
3c95241b
//
// JDKeplerSDK.h
// JDKeplerSDK
//
// Created by JD.K on 16/3/15.
// Copyright © 2016年 JD.K. All rights reserved.
//
#import <UIKit/UIKit.h>
//! Project version number for JDKeplerSDK.
FOUNDATION_EXPORT
double
JDKeplerSDKVersionNumber
;
//! Project version string for JDKeplerSDK.
FOUNDATION_EXPORT
const
unsigned
char
JDKeplerSDKVersionString
[];
// In this header, you should import all the public headers of your framework using statements like #import <JDKeplerSDK/PublicHeader.h>
#import<JDSDK/KeplerApiManager.h>
ios/Framework/JDSDK.framework/Headers/KeplerApiManager.h
0 → 100755
View file @
3c95241b
//
// KeplerApiManager.h
// KeplerApp
// 提供Kepler服务
// Created by JD.K on 16/6/20.
// Copyright © 2016年 JD.K. All rights reserved.
// version 3.0.1
#import <Foundation/Foundation.h>
#import <UIKit/UIKit.h>
/** 初始化成功回调 */
typedef
void
(
^
initSuccessCallback
)();
/** 初始化失败回调 */
typedef
void
(
^
initFailedCallback
)(
NSError
*
_Nonnull
error
);
/**
打开成功回调
*/
typedef
void
(
^
OpenSuccessBlock
)();
/**
* 响应失败的错误回调,返回一个错误的链接或信息
*/
typedef
void
(
^
OpenFailedBlock
)(
NSInteger
code
,
NSString
*
_Nonnull
url
);
typedef
enum
{
KeplerErrorCodeUnInstalled
=
422
,
//未安装京东app
KeplerErrorCodeWhited
,
//本地url不在白名单中
KeplerErrorCodeResponsed
,
//本地呼起open协议失败
KeplerErrorCodeNoSid
,
//sid为空
KeplerErrorCodeInValidApp
//应用不合法
}
KeplerErrorCode
;
@interface
KeplerApiManager
:
NSObject
/**
分佣的 AppKey2
*/
@property
(
nonatomic
,
copy
)
NSString
*
secondAppKey
;
//********************************* 通过京东APP打开链接相关参数 ************************************
/**
当isOpenByH5为 NO 时,准备跳转到JD APP时会调用这些代码。可以把开启 Loading动画的代码放到这里
为避免造成混乱,在关闭Kepler界面时,会置为nil。因此需要在每次打开Kepler之前单独设置。
*/
@property
(
nonatomic
,
copy
)
void
(
^
startOpenJDAppBlock
)();
/**
当isOpenByH5为 NO 时,跳转JD APP准备工作完成时会调用这些代码,success为YES表示成功,可以打开JD APP,为NO时表示打开失败。
为避免造成混乱,在关闭Kepler界面时,会置为nil。因此需要在每次打开Kepler之前单独设置。
update: success为NO且错误码等于-1005时,安全id为空
*/
@property
(
nonatomic
,
copy
)
void
(
^
finishOpenJDAppBlock
)(
BOOL
success
,
NSError
*
error
);
/**
* 京东达人内容ID 关闭kepler界面时会清除 如果需要此值 再次打开需要再次设置
**/
@property
(
nonatomic
,
copy
)
NSString
*
actId
;
/**
* 京东达人 内容渠道扩展字段 关闭kepler界面时会清除 如果需要此值 再次打开需要再次设置
**/
@property
(
nonatomic
,
copy
)
NSString
*
ext
;
/**
* 是否走服务端的渠道,默认走本地渠道
*/
@property
(
nonatomic
,
assign
)
BOOL
isServerChannel
;
/**
打开京东超时时间设置 关闭 Kepler 界面时不会重置 默认为60
*/
@property
(
nonatomic
,
assign
)
NSTimeInterval
openJDTimeout
;
//*******************************************************************************************************
/**
* KeplerApiManager 单例
*
* @return KeplerApiManager 单例
*/
+
(
KeplerApiManager
*
)
sharedKPService
;
/**
* 注册Kepler 服务
*
* @param appKey 注册的appKey
* @param appSecret 注册的secretKey
*/
-
(
void
)
asyncInitSdk
:(
NSString
*
)
appKey
secretKey
:(
NSString
*
)
appSecret
sucessCallback
:(
initSuccessCallback
)
sucessCallback
failedCallback
:(
initFailedCallback
)
failedCallback
;
/**
跳转京东app
@param url 调用方传入的URl参数
@param userInfo 调用sdk时传入的kepler自定义参数
@param failedCallback code 表示错误编码, url 引起调用失败的url
*/
-
(
void
)
openKeplerPageWithURL
:(
NSString
*
)
url
userInfo
:(
NSDictionary
*
)
userInfo
successCallback
:(
OpenSuccessBlock
_Nullable
)
success
failedCallback
:(
OpenFailedBlock
_Nonnull
)
failure
;
@end
ios/Framework/JDSDK.framework/Info.plist
0 → 100755
View file @
3c95241b
File added
ios/Framework/JDSDK.framework/JDSDK
0 → 100755
View file @
3c95241b
File added
ios/Framework/JDSDK.framework/Modules/module.modulemap
0 → 100755
View file @
3c95241b
framework module JDKeplerSDK {
umbrella header "JDKeplerSDK.h"
export *
module * { export * }
}
ios/jdsdk.podspec
→
ios/jd
_
sdk.podspec
View file @
3c95241b
...
...
@@ -3,8 +3,8 @@
# Run `pod lib lint jdsdk.podspec' to validate before publishing.
#
Pod
::
Spec
.
new
do
|
s
|
s
.
name
=
'jdsdk'
s
.
version
=
'
0.0.1
'
s
.
name
=
'jd
_
sdk'
s
.
version
=
'
1.0.0
'
s
.
summary
=
'A new Flutter plugin.'
s
.
description
=
<<-
DESC
A new Flutter plugin.
...
...
@@ -15,11 +15,18 @@ A new Flutter plugin.
s
.
source
=
{
:path
=>
'.'
}
s
.
source_files
=
'Classes/**/*'
s
.
public_header_files
=
'Classes/**/*.h'
s
.
dependency
'Flutter'
# 京东导入
s
.
platform
=
:ios
,
'10.0'
s
.
preserve_paths
=
'JDSDK.framework'
s
.
xcconfig
=
{
'OTHER_LDFLAGS'
=>
'-framework JDSDK'
}
s
.
vendored_frameworks
=
'Framework/JDSDK.framework'
s
.
platform
=
:ios
,
'8.0'
s
.
dependency
'Flutter'
s
.
static_framework
=
true
s
.
libraries
=
"c++.tbd"
s
.
libraries
=
"z"
# Flutter.framework does not contain a i386 slice. Only x86_64 simulators are supported.
s
.
pod_target_xcconfig
=
{
'DEFINES_MODULE'
=>
'YES'
,
'VALID_ARCHS[sdk=iphonesimulator*]'
=>
'x86_64'
}
...
...
lib/jdsdk.dart
View file @
3c95241b
...
...
@@ -5,12 +5,11 @@ import 'package:flutter/services.dart';
class
Jdsdk
{
static
const
MethodChannel
_channel
=
const
MethodChannel
(
'jdsdk'
);
static
Future
<
String
>
get
platformVersion
async
{
final
String
version
=
await
_channel
.
invokeMethod
(
'getPlatformVersion'
);
return
version
;
}
///初始化sdk
///
/// 初始化京东sdk
/// [appKey] appKey
/// [appSecret] app密钥
///
static
Future
<
String
>
init
(
{
@required
String
appKey
,
@required
String
appSecret
})
async
{
final
String
version
=
await
_channel
...
...
@@ -18,7 +17,10 @@ class Jdsdk {
return
version
;
}
///打开京东任意url
///
/// 打开京东的任意URL
/// [url] 待打开的url地址
///
static
Future
<
String
>
openUrl
({
@required
String
url
})
async
{
final
String
version
=
await
_channel
.
invokeMethod
(
'openUrl'
,
{
"url"
:
url
});
return
version
;
...
...
pubspec.yaml
View file @
3c95241b
name
:
jdsdk
name
:
jd
_
sdk
description
:
The implementation of Jingdong SDK on Flutter, through which you can realize the wake-up Jingdong app to open any URL of Jingdong, including product details and other functions.
version
:
0.0.1
author
:
wuchaowen <chaowen1110@gmail.com>
...
...
test/jdsdk_test.dart
View file @
3c95241b
import
'package:flutter/services.dart'
;
import
'package:flutter_test/flutter_test.dart'
;
import
'package:jdsdk/jdsdk.dart'
;
void
main
(
)
{
const
MethodChannel
channel
=
MethodChannel
(
'jdsdk'
);
...
...
@@ -16,8 +15,4 @@ void main() {
tearDown
(()
{
channel
.
setMockMethodCallHandler
(
null
);
});
test
(
'getPlatformVersion'
,
()
async
{
expect
(
await
Jdsdk
.
platformVersion
,
'42'
);
});
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment