/********* DDPlugin.m Cordova Plugin Implementation *******/

#import <Cordova/CDV.h>
#import<DIOpenSDK/DIOpenSDK.h>
@interface DDPlugin : CDVPlugin<DIOpenSDKDelegate> {
  // Member variables go here.
}

- (void)openDiDi:(CDVInvokedUrlCommand*)command;
@end

@implementation DDPlugin

- (void)viewDidLoad {
    //[super viewDidLoad];

    //滴滴出行：
    [DIOpenSDK registerApp:@"didi6358574A5079702B68447976547377" secret:@"f14aed32707f69ae23e7858c1fd29e4e"];

}

- (void)openDiDi:(CDVInvokedUrlCommand*)command
{


    [self.commandDelegate runInBackground:^{



     //注册option
                DIOpenSDKRegisterOptions * diOption = [[DIOpenSDKRegisterOptions alloc]init];
                //打开界面
                [DIOpenSDK showDDPage:self.viewController animated:true params:diOption delegate:self.viewController];


        id level = [command argumentAtIndex:0];
        id message = [command argumentAtIndex:1];

        if ([level isEqualToString:@"openDiDi"]) {
            NSLog(@"%@", message);





        } else {

            NSLog(@"%@: %@", level, message);
        }

    }];

//
//    let diOption = DIOpenSDKRegisterOptions()
//
//    DIOpenSDK.showDDPage(self, animated: true, params: diOption, delegate: self)


//    CDVPluginResult* pluginResult = nil;
//    NSString* echo = [command.arguments objectAtIndex:0];
//
//    if (echo != nil && [echo length] > 0) {
//        pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:echo];
//    } else {
//        pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR];
//    }
//
//    [self.commandDelegate sendPluginResult:pluginResult callbackId:command.callbackId];
}

@end
