blob: 046f15fec3eab5f96b2146b19b87527abbb349ad [file] [log] [blame]
// 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 "FLTPackageInfoPlugin.h"
@implementation FLTPackageInfoPlugin
+ (void)registerWithRegistrar:(NSObject<FlutterPluginRegistrar>*)registrar {
FlutterMethodChannel* channel =
[FlutterMethodChannel methodChannelWithName:@"plugins.flutter.io/package_info"
binaryMessenger:[registrar messenger]];
FLTPackageInfoPlugin* instance = [[FLTPackageInfoPlugin 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"]
?: [NSNull null],
@"packageName" : [[NSBundle mainBundle] bundleIdentifier] ?: [NSNull null],
@"version" : [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleShortVersionString"]
?: [NSNull null],
@"buildNumber" : [[NSBundle mainBundle] objectForInfoDictionaryKey:@"CFBundleVersion"]
?: [NSNull null],
});
} else {
result(FlutterMethodNotImplemented);
}
}
@end