.h:
#import <Foundation/Foundation.h>
typedef enum _XLBadgeManagedType {
XLInboxManagedMethod = 0,
XLDeveloperManagedMethod = 1
} XLBadgeManagedType ;
@interface XLXtifyOptions :NSObject
{
NSString *xoAppKey;
BOOL xoLocationRequired ;
BOOL xoBackgroundLocationRequired ;
BOOL xoLogging ;
BOOL xoMultipleMarkets;
XLBadgeManagedType xoManageBadge;
}
+ (XLXtifyOptions *)getXtifyOptions;
- (NSString *)getAppKey ;
- (BOOL) isLocationRequired;
- (BOOL) isBackgroundLocationRequired ;
- (BOOL) isLogging ;
- (BOOL) isMultipleMarkets;
- (XLBadgeManagedType) getManageBadgeType;
- (void)xtLogMessage:(NSString *)header content:(NSString *)message, ...;
@end
他们:
#import "XLXtifyOptions.h"
#import "XtifyGlobal.h"
static XLXtifyOptions *xXtifyOptions=nil;
@implementation XLXtifyOptions
+ (XLXtifyOptions *)getXtifyOptions
{
if (xXtifyOptions==nil) {
xXtifyOptions=[[XLXtifyOptions alloc]init];
}
return xXtifyOptions;
}
-(id)init
{
if (self = [super init]) {
xoAppKey=xAppKey;
xoLocationRequired=xLocationRequired;
xoBackgroundLocationRequired=xRunAlsoInBackground ;
xoLogging =xLogging ;
xoMultipleMarkets=xMultipleMarkets;
xoManageBadge=xBadgeManagerMethod;
}
return self;
}
- (NSString *)getAppKey
{
return xoAppKey;
}
- (BOOL) isLocationRequired
{
return xoLocationRequired;
}
- (BOOL) isBackgroundLocationRequired
{
return xoBackgroundLocationRequired;
}
- (BOOL) isLogging
{
return xoLogging;
}
- (BOOL) isMultipleMarkets
{
return xoMultipleMarkets;
}
- (XLBadgeManagedType) getManageBadgeType
{
return xoManageBadge;
}
- (void)xtLogMessage:(NSString *)header content:(NSString *)format, ... {
va_list args;
va_start(args, format);
if (xoLogging) {
NSString *prettyFmt=[NSString stringWithFormat:@"%@ %@", header,format];
NSLogv(prettyFmt, args);
}
va_end(args);
}
@end
全球.h:
#define xAppKey @"abc123"
#define xLocationRequired NO
#define xRunAlsoInBackground FALSE
#define xBadgeManagerMethod XLInboxManagedMethod
#define xLogging TRUE
#define xMultipleMarkets FALSE
我的绑定定义:
[BaseType (typeof (NSObject))]
public interface XLXtifyOptions {
[Static]
[Export ("xtifyOptions")]
XLXtifyOptions Options { get;}
[Export ("getAppKey")]
string GetAppKey ();
[Export ("isLocationRequired")]
bool IsLocationRequired ();
[Export ("isBackgroundLocationRequired")]
bool IsBackgroundLocationRequired ();
[Export ("isLogging")]
bool IsLogging ();
[Export ("isMultipleMarkets")]
bool IsMultipleMarkets ();
[Export ("getManageBadgeType")]
XLBadgeManagedType GetManageBadgeType ();
// [Export ("xtLogMessage:content:...")]
// void XtLogMessagecontent... (string header, string message,, );
//
}
这些返回 null:
XLXtifyOptions.Options;
new XLXtifyOptions().GetAppKey();
供应商入门说明:
XLXtifyOptions *anXtifyOptions=[Options getVendorOptions];
[[TheirClass get ]initilizeXoptions:anVendorOptions];
我匆忙尝试重命名一些东西,因为我不确定供应商的代码有多少可以粘贴,所以希望我没有混淆。
这与:Binding #define used as constant
更多信息:
如果我在设备而不是模拟器上运行它,我会收到以下错误:
Unhandled managed exception: Wrapper type 'XtifyPush.XLXtifyOptions' is missing its native ObjectiveC class 'XLXtifyOptions'.
编辑
回复@Stephane:我更新了代码以不再掩盖供应商。我绑定的是: http: //developer.xtify.com/display/sdk/Getting+Started+with+Apple+Push+Notification+Service,fwiw。我按照您的建议更新了对 getXtifyOptions 的引用,但结果相同。我对您引用的 github 库的了解已尽,但我会继续挖掘。
我正在处理的绑定可在以下位置获得:https ://github.com/lordscarlet/monotouch-bindings/tree/master/Xtify