私はiPhone
過去 2 年間、ネイティブ アプリケーションを開発しています。しかし今、私は学ぼうとしていますphone gap
。スタート ページとして使用する phone gapのサンプルを見てきましたが、と の両方を使用しindex.html
てアプリを作成したいと考えています。また、私にとって役立つチュートリアルがあれば、多くのチュートリアルを見てきましたが、すべて古いもので、私の Xcode 4.5 では動作しません。native
phone gap
viewController
navigationBar
tabBarController
2 に答える
2
プラグインの助けを借りて、電話のギャップでネイティブコードを使用できます。たとえば、コードを貼り付けています
#import <UIKit/UIKit.h>
#import <Cordova/CDVPlugin.h>
@interface PushToken : CDVPlugin
{
NSString* callbackID;
}
@property (nonatomic, copy) NSString* callbackID;
- (void) getToken:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options;
@end
#import "PushToken.h"
#import "AppDelegate.h"
@implementation PushToken
@synthesize callbackID;
-(void)getToken:(NSMutableArray*)arguments withDict:(NSMutableDictionary*)options {
self.callbackID = [arguments pop];
NSString *token = ((AppDelegate *)[[UIApplication sharedApplication] delegate]).token;
CDVPluginResult* pluginResult = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsString:[token stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding]];
if(token.length != 0)
{
[self writeJavascript: [pluginResult toSuccessCallbackString:self.callbackID]];
}else {
[self writeJavascript: [pluginResult toErrorCallbackString:self.callbackID]];
}
}
@end
.js file
var PushToken = {
getToken: function(types, success, fail) {
return cordova.exec(success, fail, "PushToken", "getToken", types);
}
};
including .js file
<script src="PushToken.js"></script>
calling
PushToken.getToken(
["getToken"] ,
function(token) {
devToken = token;
//navigator.notification.alert(devToken);
},
function(error) {
navigator.notification.alert("Error :Token Not Found "+error);
}
);
may be helpful
thanks
于 2012-12-19T06:57:24.647 に答える
0
于 2012-12-19T06:48:13.043 に答える