/
FLTPackageInfoPlusPlugin.m
39 lines (35 loc) · 1.46 KB
/
FLTPackageInfoPlusPlugin.m
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
// Copyright 2017 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
#import "FLTPackageInfoPlusPlugin.h"
@implementation FLTPackageInfoPlusPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar> *)registrar {
FlutterMethodChannel *channel = [FlutterMethodChannel
methodChannelWithName:@"dev.fluttercommunity.plus/package_info"
binaryMessenger:[registrar messenger]];
FLTPackageInfoPlusPlugin *instance = [[FLTPackageInfoPlusPlugin alloc] init];
[registrar addMethodCallDelegate:instance channel:channel];
}
- (void)handleMethodCall:(FlutterMethodCall *)call
result:(FlutterResult)result {
if ([call.method isEqualToString:@"getAll"]) {
result(@{
@"appName" : [[NSBundle mainBundle]
objectForInfoDictionaryKey:@"CFBundleDisplayName"]
?: [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleName"]
?: [NSNull null],
@"packageName" : [[NSBundle mainBundle] bundleIdentifier]
?: [NSNull null],
@"version" : [[NSBundle mainBundle]
objectForInfoDictionaryKey:@"CFBundleShortVersionString"]
?: [NSNull null],
@"buildNumber" : [[NSBundle mainBundle]
objectForInfoDictionaryKey:@"CFBundleVersion"]
?: [NSNull null],
@"installerStore" : [NSNull null]
});
} else {
result(FlutterMethodNotImplemented);
}
}
@end