Skip to content

Commit 405e0aa

Browse files
committed
read修改
1 parent 7452137 commit 405e0aa

File tree

8 files changed

+73
-27
lines changed

8 files changed

+73
-27
lines changed

android/src/main/java/com/havaid/app/flutter_getuuid/FlutterGetuuidPlugin.java

+18
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,9 @@ else if (call.method.equals("getsystemMark")){
4444
else if (call.method.equals("getCurrentDeviceModel")){
4545
result.success(getCurrentDeviceModel());
4646
}
47+
else if (call.method.equals("getVersionName")){
48+
result.success(getVersionName(context));
49+
}
4750
else {
4851
result.notImplemented();
4952
}
@@ -83,6 +86,21 @@ public String getVersionCode(Context context)
8386
return versionCode+"";
8487
}
8588

89+
// 获取版本Name
90+
public String getVersionName(Context context)
91+
{
92+
String versionName="";
93+
try
94+
{
95+
versionName = context.getPackageManager().getPackageInfo(context.getPackageName() , PackageManager.GET_CONFIGURATIONS).versionName;
96+
}
97+
catch (PackageManager.NameNotFoundException e)
98+
{
99+
e.printStackTrace();
100+
}
101+
return versionName;
102+
}
103+
86104
// 系统使用的SDK版本
87105
private String getsystemMark()
88106
{

example/ios/Podfile.lock

+4-4
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ DEPENDENCIES:
1111
- SAMKeychain
1212

1313
SPEC REPOS:
14-
https://github.com/cocoapods/specs.git:
14+
https://github.com/CocoaPods/Specs.git:
1515
- SAMKeychain
1616

1717
EXTERNAL SOURCES:
@@ -21,10 +21,10 @@ EXTERNAL SOURCES:
2121
:path: ".symlinks/plugins/flutter_getuuid/ios"
2222

2323
SPEC CHECKSUMS:
24-
Flutter: 9d0fac939486c9aba2809b7982dfdbb47a7b0296
25-
flutter_getuuid: f7a0b845e3162c2605590394968ca577d3f68fb4
24+
Flutter: 0e3d915762c693b495b44d77113d4970485de6ec
25+
flutter_getuuid: 34f3fdde26ffaa35b000d858f48c21ea7db02c7b
2626
SAMKeychain: 483e1c9f32984d50ca961e26818a534283b4cd5c
2727

2828
PODFILE CHECKSUM: 0f956c7cec0f749da0152930ba0e16c31f30256b
2929

30-
COCOAPODS: 1.5.3
30+
COCOAPODS: 1.8.3

example/ios/Runner.xcodeproj/project.pbxproj

+10-12
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@
3838
/* End PBXCopyFilesBuildPhase section */
3939

4040
/* Begin PBXFileReference section */
41+
09CE1CBA87692F9DEB0E9907 /* 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>"; };
4142
1498D2321E8E86230040F4C2 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
4243
1498D2331E8E89220040F4C2 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
4344
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
@@ -54,7 +55,9 @@
5455
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
5556
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
5657
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
58+
AFD0C12E7C2ABB4FAB95F665 /* 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>"; };
5759
D2BB521ECB3D252284E0CAF4 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
60+
F1AD44A81CE48D52033F9532 /* Pods-Runner.profile.xcconfig */ = {isa = PBXFileReference; includeInIndex = 1; lastKnownFileType = text.xcconfig; name = "Pods-Runner.profile.xcconfig"; path = "Pods/Target Support Files/Pods-Runner/Pods-Runner.profile.xcconfig"; sourceTree = "<group>"; };
5861
/* End PBXFileReference section */
5962

6063
/* Begin PBXFrameworksBuildPhase section */
@@ -82,6 +85,9 @@
8285
4BD5C350BDF012E75DCBF57F /* Pods */ = {
8386
isa = PBXGroup;
8487
children = (
88+
AFD0C12E7C2ABB4FAB95F665 /* Pods-Runner.debug.xcconfig */,
89+
09CE1CBA87692F9DEB0E9907 /* Pods-Runner.release.xcconfig */,
90+
F1AD44A81CE48D52033F9532 /* Pods-Runner.profile.xcconfig */,
8591
);
8692
name = Pods;
8793
sourceTree = "<group>";
@@ -226,21 +232,17 @@
226232
buildActionMask = 2147483647;
227233
files = (
228234
);
229-
inputFileListPaths = (
230-
);
231235
inputPaths = (
232-
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
236+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
233237
"${PODS_ROOT}/../.symlinks/flutter/ios/Flutter.framework",
234238
);
235239
name = "[CP] Embed Pods Frameworks";
236-
outputFileListPaths = (
237-
);
238240
outputPaths = (
239241
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
240242
);
241243
runOnlyForDeploymentPostprocessing = 0;
242244
shellPath = /bin/sh;
243-
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
245+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh\"\n";
244246
showEnvVarsInLog = 0;
245247
};
246248
3B06AD1E1E4923F5004D2608 /* Thin Binary */ = {
@@ -262,21 +264,17 @@
262264
buildActionMask = 2147483647;
263265
files = (
264266
);
265-
inputFileListPaths = (
266-
);
267267
inputPaths = (
268-
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-resources.sh",
268+
"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh",
269269
"${PODS_ROOT}/SAMKeychain/Support/SAMKeychain.bundle",
270270
);
271271
name = "[CP] Copy Pods Resources";
272-
outputFileListPaths = (
273-
);
274272
outputPaths = (
275273
"${TARGET_BUILD_DIR}/${UNLOCALIZED_RESOURCES_FOLDER_PATH}/SAMKeychain.bundle",
276274
);
277275
runOnlyForDeploymentPostprocessing = 0;
278276
shellPath = /bin/sh;
279-
shellScript = "\"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
277+
shellScript = "\"${PODS_ROOT}/Target Support Files/Pods-Runner/Pods-Runner-resources.sh\"\n";
280278
showEnvVarsInLog = 0;
281279
};
282280
9740EEB61CF901F6004384FC /* Run Script */ = {

example/lib/main.dart

+1-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ class _MyAppState extends State<MyApp> {
2525
String platformVersion;
2626
// Platform messages may fail, so we use a try/catch PlatformException.
2727
try {
28-
platformVersion = await FlutterGetuuid.platformDeviceModle;
28+
platformVersion = await FlutterGetuuid.platformVersionName;
2929
} on PlatformException {
3030
platformVersion = 'Failed to get platform uid.';
3131
}

flutter_getuuid.iml

+14
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,20 @@
1111
<excludeFolder url="file://$MODULE_DIR$/example/.dart_tool" />
1212
<excludeFolder url="file://$MODULE_DIR$/example/.pub" />
1313
<excludeFolder url="file://$MODULE_DIR$/example/build" />
14+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/.dart_tool" />
15+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/.pub" />
16+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/build" />
17+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/example/.dart_tool" />
18+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/example/.pub" />
19+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/example/build" />
20+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/example/build/app/intermediates/flutter/debug/android-arm/flutter_assets/packages" />
21+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/example/build/app/intermediates/flutter/debug/android-arm64/flutter_assets/packages" />
22+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/example/build/app/intermediates/flutter/debug/flutter_assets/packages" />
23+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/example/build/app/intermediates/merged_assets/debug/mergeDebugAssets/out/flutter_assets/packages" />
24+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/example/build/flutter_assets/packages" />
25+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/example/build/ios/Debug-iphonesimulator/Runner.app/Frameworks/App.framework/flutter_assets/packages" />
26+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/example/build/ios/iphonesimulator/Runner.app/Frameworks/App.framework/flutter_assets/packages" />
27+
<excludeFolder url="file://$MODULE_DIR$/example/ios/.symlinks/plugins/flutter_getuuid/example/ios/Flutter/App.framework/flutter_assets/packages" />
1428
<excludeFolder url="file://$MODULE_DIR$/example/ios/Flutter/App.framework/flutter_assets/packages" />
1529
</content>
1630
<orderEntry type="sourceFolder" forTests="false" />

ios/Classes/FlutterGetuuidPlugin.m

+11
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ - (void)handleMethodCall:(FlutterMethodCall*)call result:(FlutterResult)result {
2525
else if([@"getVersionCode" isEqualToString:call.method]){
2626
result([@"" stringByAppendingString:[self getVersionCode]]);
2727
}
28+
else if([@"getVersionName" isEqualToString:call.method]){
29+
result([@"" stringByAppendingString:[self getVersionName]]);
30+
}
2831
else{
2932
result(FlutterMethodNotImplemented);
3033
}
@@ -144,4 +147,12 @@ - (NSString *)getVersionCode {
144147
NSString *appVersion = [infoDic objectForKey:@"CFBundleVersion"];
145148
return appVersion;
146149
}
150+
151+
// 获取app版本名称
152+
- (NSString *)getVersionName {
153+
NSDictionary *infoDic = [[NSBundle mainBundle] infoDictionary];
154+
// 获取App的版本号
155+
NSString *appVersionName = [infoDic objectForKey:@"CFBundleShortVersionString"];
156+
return appVersionName;
157+
}
147158
@end

lib/flutter_getuuid.dart

+5
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,9 @@ class FlutterGetuuid {
3131
return systemMark;
3232
}
3333

34+
static Future<String> get platformVersionName async {
35+
final String versionName = await _channel.invokeMethod('getVersionName');
36+
return versionName;
37+
}
38+
3439
}

pubspec.lock

+10-10
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
11
# Generated by pub
2-
# See https://www.dartlang.org/tools/pub/glossary#lockfile
2+
# See https://dart.dev/tools/pub/glossary#lockfile
33
packages:
44
async:
55
dependency: transitive
66
description:
77
name: async
88
url: "https://pub.flutter-io.cn"
99
source: hosted
10-
version: "2.1.0"
10+
version: "2.3.0"
1111
boolean_selector:
1212
dependency: transitive
1313
description:
1414
name: boolean_selector
1515
url: "https://pub.flutter-io.cn"
1616
source: hosted
17-
version: "1.0.4"
17+
version: "1.0.5"
1818
charcode:
1919
dependency: transitive
2020
description:
@@ -52,28 +52,28 @@ packages:
5252
name: meta
5353
url: "https://pub.flutter-io.cn"
5454
source: hosted
55-
version: "1.1.6"
55+
version: "1.1.7"
5656
path:
5757
dependency: transitive
5858
description:
5959
name: path
6060
url: "https://pub.flutter-io.cn"
6161
source: hosted
62-
version: "1.6.2"
62+
version: "1.6.4"
6363
pedantic:
6464
dependency: transitive
6565
description:
6666
name: pedantic
6767
url: "https://pub.flutter-io.cn"
6868
source: hosted
69-
version: "1.5.0"
69+
version: "1.8.0+1"
7070
quiver:
7171
dependency: transitive
7272
description:
7373
name: quiver
7474
url: "https://pub.flutter-io.cn"
7575
source: hosted
76-
version: "2.0.2"
76+
version: "2.0.5"
7777
sky_engine:
7878
dependency: transitive
7979
description: flutter
@@ -106,7 +106,7 @@ packages:
106106
name: string_scanner
107107
url: "https://pub.flutter-io.cn"
108108
source: hosted
109-
version: "1.0.4"
109+
version: "1.0.5"
110110
term_glyph:
111111
dependency: transitive
112112
description:
@@ -120,7 +120,7 @@ packages:
120120
name: test_api
121121
url: "https://pub.flutter-io.cn"
122122
source: hosted
123-
version: "0.2.4"
123+
version: "0.2.5"
124124
typed_data:
125125
dependency: transitive
126126
description:
@@ -136,4 +136,4 @@ packages:
136136
source: hosted
137137
version: "2.0.8"
138138
sdks:
139-
dart: ">=2.2.0 <3.0.0"
139+
dart: ">=2.2.2 <3.0.0"

0 commit comments

Comments
 (0)