2015-05-07 76 views

回答

0

我發現我可以多次致電成功。
我修改這個"hello world plugin" for Cordova再打兩次(這當然可以延長):

#import "HWPHello.h" 

@implementation HWPHello 

- (void)greet:(CDVInvokedUrlCommand*)command 
{ 
    NSString* name = [[command arguments] objectAtIndex:0]; 
    NSString* msg = [NSString stringWithFormat: @"Welcome Mr. %@", name]; 

    CDVPluginResult* result = [CDVPluginResult 
           resultWithStatus:CDVCommandStatus_OK 
           messageAsString:msg]; 

    // Set the KeepCallback before sending the result will keep the callback id for further callbacks 
    [result setKeepCallbackAsBool:YES]; 
    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; 

    msg = [NSString stringWithFormat: @"Hi Mr. %@", name]; 
    result = [CDVPluginResult 
            resultWithStatus:CDVCommandStatus_OK 
            messageAsString:msg]; 
    [self.commandDelegate sendPluginResult:result callbackId:command.callbackId]; 
} 

@end