objective c - calling javascript event strings in to native iOS calendar iPHone -
we have develop iphone application in phonegap environment. call below javascritpt function in objective-c xcode create event in native ios calendar.
//calendar.js var calendarplugin = { createevent: function(title, location, notes, startdate, enddate, successcallback, errorcallback) { cordova.exec( successcallback, // success callback function errorcallback, // error callback function 'calendarplugin', // mapped our native java class called "calendarplugin" 'addcalendarentry', // action name [{ // , array of custom arguments create our entry "title": title, "description": notes, "eventlocation": location, "starttimemillis": startdate.gettime(), "endtimemillis": enddate.gettime() }] ); }
}
i have basic code of calendar event in objective c, need pass string value javascript calendar event obj-c method. write in below webview method
- (bool)webview:(uiwebview*)thewebview shouldstartloadwithrequest:(nsurlrequest*)request navigationtype:(uiwebviewnavigationtype)navigationtype
i'm not sure calendar part, 1 can out.
make sure define plugin in config.xml
<feature name="customplugin"> <param name="ios-package" value="customplugin" /> </feature>
implementing plug-in using objective-c code
customplugin.h
#import <foundation/foundation.h> #import <cordova/cdv.h> @interface customplugin : cdvplugin - (void)sayhello:(cdvinvokedurlcommand*)command; @end
customplugin.m
#import "customplugin.h" @implementation customplugin - (void)sayhello:(cdvinvokedurlcommand*)command{ nsstring *responsestring = [nsstring stringwithformat:@"hello world, %@", [command.arguments objectatindex:0]]; cdvpluginresult *pluginresult = [cdvpluginresult resultwithstatus:cdvcommandstatus_ok messageasstring:responsestring]; [self.commanddelegate sendpluginresult:pluginresult callbackid:command.callbackid]; } @end
calling plug-in javascript
function initial(){ var name = $("#nameinput").val(); cordova.exec(sayhellosuccess, sayhellofailure, "customplugin", "sayhello", [name]); } function sayhellosuccess(data){ alert("ok: " + data); } function sayhellofailure(data){ alert("fail: " + data); }
Comments
Post a Comment