Files
checker/ios/Runner/AppDelegate.m
2018-06-19 15:24:46 +07:00

136 lines
5.9 KiB
Objective-C

#include "AppDelegate.h"
#include "GeneratedPluginRegistrant.h"
#import "Autobonus-Swift.h"
@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
[GeneratedPluginRegistrant registerWithRegistry:self];
FlutterViewController* controller = (FlutterViewController*)self.window.rootViewController;
FlutterMethodChannel* platformChannel = [FlutterMethodChannel
methodChannelWithName:@"com.dinect.checker/instance_id"
binaryMessenger:controller];
__weak FlutterMethodChannel* weekPlatformChannel = platformChannel;
NSString *bundleIdentifier = [[NSBundle mainBundle] bundleIdentifier];
NSDictionary *settings = @{
@"com.dinect.checker.dinect.app" : @{
@"locale" : @"ru",
@"flavor" : @"dinect",
@"currency" : @643,
@"supportPhone" : @"support@dinect.com",
@"supportUrl" : @"http://www.dinect.com",
@"endPoint" : @"https://pos-api.dinect.com/20130701/",
@"appToken" : @"bdea0f3ba9034b688019a7cac753d1209e2b227f",
@"appTitle" : @"Чекер",
@"showBonus" : @YES,
},
@"com.dinect.develop-iOS" : @{
@"locale" : @"ru",
@"flavor" : @"dinect",
@"currency" : @643,
@"supportPhone" : @"support@dinect.com",
@"supportUrl" : @"http://yandex.ru",
@"endPoint" : @"https://pos-api-int.dinect.com/20130701/",
@"appToken" : @"9fec83cdca38c357e6b65dbb17514cdd36bf2a08",
@"appTitle" : @"Dinect (INT)",
@"showBonus" : @YES,
},
@"com.dinect.checker.autoclub.app" : @{
@"locale" : @"ru",
@"flavor" : @"autobonus",
@"currency" : @643,
@"supportPhone" : @"Обратитесь к вашему региональному менеджеру",
@"supportUrl" : @"https://www.auto-club.biz/coupons_new/contacts",
@"endPoint" : @"https://pos-api-autoclub.dinect.com/20130701/",
@"appToken" : @"bdea0f3ba9034b688019a7cac753d1209e2b227f",
@"appTitle" : @"Autobonus",
@"showBonus" : @NO,
},
@"digital.joys.checker" : @{
@"locale" : @"ru",
@"flavor" : @"crypto",
@"currency" : @643,
@"supportPhone" : @"support@joys.digital",
@"supportUrl" : @"https://joys.digital/",
@"endPoint" : @"https://pos-api-crypto-int.dinect.com/20130701/",
@"appToken" : @"bdea0f3ba9034b688019a7cac753d1209e2b227f",
@"appTitle" : @"POSapp Joys",
@"showBonus" : @YES,
},
@"com.dinect.checker.pip" : @{
@"locale" : @"ua",
@"flavor" : @"pip",
@"currency" : @980,
@"supportPhone" : @"+38 080 030 9997\n+38 044 390 1697",
@"supportUrl" : @"http://discount.kiev.ua/",
@"endPoint" : @"https://pos-api.discount.kiev.ua/20130701/",
@"appToken" : @"bdea0f3ba9034b688019a7cac753d1209e2b227f",
@"appTitle" : @"PIP",
@"showBonus" : @YES,
},
@"ru.fivefit.biochecker" : @{
@"locale" : @"ru",
@"flavor" : @"biohacker",
@"currency" : @643,
@"supportPhone" : @"support@dinect.com",
@"supportUrl" : @"http://www.dinect.com",
@"endPoint" : @"https://pos-api.dinect.com/20130701/",
@"appToken" : @"bdea0f3ba9034b688019a7cac753d1209e2b227f",
@"appTitle" : @"BioChecker",
@"showBonus" : @YES,
},
};
NSDictionary *buildSettings = settings[bundleIdentifier];
if (!buildSettings) {
NSLog(@"Settings for this bunndle id not defined (%@)", bundleIdentifier);
abort();
}
[platformChannel setMethodCallHandler:^(FlutterMethodCall* call, FlutterResult result) {
NSLog(@"%@", call.method);
if ([@"getLocale" isEqualToString:call.method]) {
result(buildSettings[@"locale"]);
} else if ([@"getFlavor" isEqualToString:call.method]) {
result(buildSettings[@"flavor"]);
} else if ([@"getCurrency" isEqualToString:call.method]) {
result(buildSettings[@"currency"]);
} else if ([@"startScanner" isEqualToString:call.method]) {
ScannerViewController *modalViewController = [[ScannerViewController alloc] initWithStrings:call.arguments];
modalViewController.platformChannel = weekPlatformChannel;
[controller presentViewController:modalViewController animated:YES completion:nil];
} else if ([@"isOnline" isEqualToString:call.method]) {
result(@YES);
} else if ([@"getSupportPhone" isEqualToString:call.method]) {
result(buildSettings[@"supportPhone"]);
} else if ([@"getSupportUrl" isEqualToString:call.method]) {
result(buildSettings[@"supportUrl"]);
} else if ([@"getEndpoint" isEqualToString:call.method]) {
result(buildSettings[@"endPoint"]);
} else if ([@"getAppToken" isEqualToString:call.method]) {
result(buildSettings[@"appToken"]);
} else if ([@"getAppTitle" isEqualToString:call.method]) {
result(buildSettings[@"appTitle"]);
} else if ([@"showBonus" isEqualToString:call.method]) {
result(buildSettings[@"showBonus"]);
} else if ([@"getVersionName" isEqualToString:call.method]) {
result([[NSBundle mainBundle] objectForInfoDictionaryKey: @"CFBundleShortVersionString"]);
} else {
result(FlutterMethodNotImplemented);
}
}];
return [super application:application didFinishLaunchingWithOptions:launchOptions];
}
@end