Question

I am an iOS and Phonegap newbie so please bear with me. I have the following code in my index.html -

function onDeviceReady()
{
    // do your thing!
    //navigator.notification.alert("PhoneGap is working");
    MyClass.nativeFunction(
         ["HelloWorld"] ,
         function(result) {
                alert("Success : \r\n"+result);      
          },

          function(error) {
                 alert("Error : \r\n"+error);      
           }
     );  

}

I have another file called MyClass.js which has the following -

var MyClass = {

nativeFunction: function(types, success, fail) {
return PhoneGap.exec(success, fail, "MyClass", "print", types);
}

}

I have an Objective C class called MyClass with the method print having an NSLog statement. But that is never reached. What is the reason for that?

Update: My .h class

#import <Foundation/Foundation.h>
#import <PhoneGap/PGPlugin.h>

@interface MyClass : PGPlugin {

    NSString* callbackID;  
}

@property (nonatomic, copy) NSString* callbackID;

//Instance Method  
- (void) print:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;

@end
Was it helpful?

Solution

Have you added your plugin to your PhoneGap.plist file?

If so, what key/value did you use? It looks to me like it should be MyClass/MyClass

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top