Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
A
alipay_no_utdid
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
李增强
alipay_no_utdid
Commits
2862c216
Commit
2862c216
authored
Mar 25, 2021
by
xgz
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
修改支付宝插件ios
parent
a7916ee1
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
127 additions
and
2 deletions
+127
-2
ios/Classes/AlipayNoUtdidPlugin.m
ios/Classes/AlipayNoUtdidPlugin.m
+124
-1
ios/Classes/SwiftAlipayNoUtdidPlugin.swift
ios/Classes/SwiftAlipayNoUtdidPlugin.swift
+1
-0
ios/alipay_no_utdid.podspec
ios/alipay_no_utdid.podspec
+2
-1
No files found.
ios/Classes/AlipayNoUtdidPlugin.m
View file @
2862c216
...
...
@@ -8,8 +8,131 @@
#import "alipay_no_utdid-Swift.h"
#endif
#import <AlipaySDK/AlipaySDK.h>
__weak
AlipayNoUtdidPlugin
*
__tobiasPlugin
;
@interface
AlipayNoUtdidPlugin
()
@property
(
readwrite
,
copy
,
nonatomic
)
FlutterResult
callback
;
@end
@implementation
AlipayNoUtdidPlugin
+
(
void
)
registerWithRegistrar
:(
NSObject
<
FlutterPluginRegistrar
>*
)
registrar
{
[
SwiftAlipayNoUtdidPlugin
registerWithRegistrar
:
registrar
];
FlutterMethodChannel
*
channel
=
[
FlutterMethodChannel
methodChannelWithName:
@"alipay_no_utdid"
binaryMessenger:
[
registrar
messenger
]];
AlipayNoUtdidPlugin
*
instance
=
[[
AlipayNoUtdidPlugin
alloc
]
init
];
[
registrar
addMethodCallDelegate
:
instance
channel
:
channel
];
[
registrar
addApplicationDelegate
:
instance
];
}
-
(
void
)
handleMethodCall
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
if
([
@"pay"
isEqualToString
:
call
.
method
])
{
[
self
pay
:
call
result
:
result
];
}
else
if
([
@"version"
isEqualToString
:
call
.
method
]){
[
self
getVersion
:
call
result
:
result
];
}
else
if
([
@"isInstalled"
isEqualToString
:
call
.
method
]){
[
self
_isAliPayInstalled
:
call
result
:
result
];
}
else
{
result
(
FlutterMethodNotImplemented
);
}
}
-
(
BOOL
)
application
:(
UIApplication
*
)
application
openURL
:(
NSURL
*
)
url
sourceApplication
:(
NSString
*
)
sourceApplication
annotation
:(
id
)
annotation
{
return
[
self
handleOpenURL
:
url
];
}
// NOTE: 9.0以后使用新API接口
-
(
BOOL
)
application
:(
UIApplication
*
)
app
openURL
:(
NSURL
*
)
url
options
:(
NSDictionary
<
NSString
*
,
id
>
*
)
options
{
return
[
self
handleOpenURL
:
url
];
}
+
(
BOOL
)
handleOpenURL
:(
NSURL
*
)
url
{
if
(
!
__tobiasPlugin
)
return
NO
;
return
[
__tobiasPlugin
handleOpenURL
:
url
];
}
-
(
BOOL
)
handleOpenURL
:(
NSURL
*
)
url
{
if
([
url
.
host
isEqualToString
:
@"safepay"
])
{
__weak
AlipayNoUtdidPlugin
*
__self
=
self
;
[[
AlipaySDK
defaultService
]
processOrderWithPaymentResult
:
url
standbyCallback
:
^
(
NSDictionary
*
resultDic
)
{
[
__self
onPayResultReceived
:
resultDic
];
}];
return
YES
;
}
return
NO
;
}
-
(
void
)
onPayResultReceived
:(
NSDictionary
*
)
resultDic
{
if
(
self
.
callback
!=
nil
){
NSMutableDictionary
*
mutableDictionary
=
[
NSMutableDictionary
dictionaryWithDictionary
:
resultDic
];
[
mutableDictionary
setValue
:
@"iOS"
forKey
:
@"platform"
];
self
.
callback
(
mutableDictionary
);
self
.
callback
=
nil
;
}
}
-
(
void
)
pay
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
NSString
*
urlScheme
=
[
self
fetchUrlScheme
];
if
(
!
urlScheme
){
result
([
FlutterError
errorWithCode
:
@"AliPay UrlScheme Not Found"
message
:
@"Config AliPay First"
details
:
nil
]);
return
;
}
[
self
_pay
:
call
result
:
result
urlScheme
:
urlScheme
];
}
-
(
void
)
_pay
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
urlScheme
:(
NSString
*
)
urlScheme
{
self
.
callback
=
result
;
__weak
AlipayNoUtdidPlugin
*
__self
=
self
;
[[
AlipaySDK
defaultService
]
payOrder
:
call
.
arguments
[
@"order"
]
fromScheme
:
urlScheme
callback
:^
(
NSDictionary
*
resultDic
)
{
[
__self
onPayResultReceived
:
resultDic
];
}];
}
-
(
void
)
getVersion
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
NSString
*
version
=
[
AlipaySDK
defaultService
].
currentVersion
;
if
(
version
==
nil
){
version
=
@""
;
}
result
(
version
);
}
-
(
NSString
*
)
fetchUrlScheme
{
NSDictionary
*
infoDic
=
[[
NSBundle
mainBundle
]
infoDictionary
];
NSArray
*
types
=
infoDic
[
@"CFBundleURLTypes"
];
for
(
NSDictionary
*
dic
in
types
){
if
([
@"alipay"
isEqualToString
:
dic
[
@"CFBundleURLName"
]]){
return
dic
[
@"CFBundleURLSchemes"
][
0
];
}
}
return
nil
;
}
-
(
void
)
_isAliPayInstalled
:(
FlutterMethodCall
*
)
call
result
:(
FlutterResult
)
result
{
BOOL
isAliPayInstalled
=
[[
UIApplication
sharedApplication
]
canOpenURL
:[
NSURL
URLWithString
:
@"alipays://"
]]
||
[[
UIApplication
sharedApplication
]
canOpenURL
:[
NSURL
URLWithString
:
@"alipay://"
]];
result
(
@
(
isAliPayInstalled
));
}
@end
ios/Classes/SwiftAlipayNoUtdidPlugin.swift
View file @
2862c216
import
Flutter
import
UIKit
public
class
SwiftAlipayNoUtdidPlugin
:
NSObject
,
FlutterPlugin
{
public
static
func
register
(
with
registrar
:
FlutterPluginRegistrar
)
{
let
channel
=
FlutterMethodChannel
(
name
:
"alipay_no_utdid"
,
binaryMessenger
:
registrar
.
messenger
())
...
...
ios/alipay_no_utdid.podspec
View file @
2862c216
...
...
@@ -14,8 +14,9 @@ A new Flutter plugin.
s
.
author
=
{
'Your Company'
=>
'email@example.com'
}
s
.
source
=
{
:path
=>
'.'
}
s
.
source_files
=
'Classes/**/*'
s
.
static_framework
=
true
s
.
dependency
'Flutter'
s
.
platform
=
:ios
,
'
8.0'
s
.
dependency
'PingppAlipaySDKNoUTDID'
,
'~> 15.
8.0'
# 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'
}
...
...
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