我有一个本机应用程序可以成功订阅/取消订阅和推送通知,但是,API 似乎没有传入我正在使用的 WLPushOptions 对象。
我的 obj c 代码中的调用:
NSLog(@"Trying to subscribe ...");
id options = [WLPushOptions new];
[options addSubscriptionParameter:@"param3" :@"Testing3"];
NSLog(@"Connecting to server and initializing push notification … ");
ReadyToSubscribeListener *readyToSubscribeListener = [[ReadyToSubscribeListener alloc] initWithContext:ctx];
readyToSubscribeListener.alias = @"iOSPushAlias";
readyToSubscribeListener.adapterName = @"PushAdapter";
readyToSubscribeListener.eventSourceName = @"PushEventSource";
NSLog(@"Creating subscribe listener...");
MySubscribeListener *mySubscribeListener = [[MySubscribeListener alloc] initWithContext:ctx];
[[WLPush sharedInstance]subscribe:@"iOSPushAlias" :options :mySubscribeListener];
NSLog(@"Finished subscribe.");
日志:
Nov 4 20:29:44 Davids-iPhone-5 xxxx [771] <Warning>: Trying to subscribe ...
Nov 4 20:29:44 Davids-iPhone-5 xxxx [771] <Warning>: [WorklightNativeExtensionTemplateiOS] Connecting to server and initializing push notification ...
Nov 4 20:29:44 Davids-iPhone-5 xxxx [771] <Warning>: Creating subscribe listener...
Nov 4 20:29:44 Davids-iPhone-5 xxxx [771] <Warning>: Finished subscribe.
Nov 4 20:29:44 Davids-iPhone-5 xxxx [771] <Warning>: [INFO] Successfully subscribed to alias iOSPushAlias
然后,在 HSQL db 日志中(使用本地 Worklight Developer 客户端):
DELETE FROM NOTIFICATION_DEVICE WHERE ID=91
INSERT INTO NOTIFICATION_DEVICE VALUES(91,'iOSPushAlias','MYAPPNAME-iOSnative-1.0','XXXXXXXX-0C65-4BEF-BE3E-098B21BDFCEF','{}','Apple','XXXXXXXX324CA75650BB85853B946F3D1D9881E5D2E4F3E02268AA6CAA3254B3','XXXXXXXXXX-debug 1.2.0 (iPhone; iPhone OS 7.0.2; en_US)',91)
COMMIT
我已经删除了应用程序和订阅 ID。
正如您在 INSERT 语句中看到的那样,第五个字段(NOTIFICATION_DEVICE 表中的 OPTIONS 字段)正在插入一个空的 JSON 对象,我在其中传入了键“param3”和值“Testing3”,所以,我希望它成为:
{'param3':'Testing3'}
这似乎是原生 iOS API 文档对 addSubscriptionParameter 方法的期望(NSString 参数)。我对Objective C很陌生,但是,这对我来说是正确的。
有人知道我在做什么错吗?