Question

I have a native app that is subscribing/unsubscribing and pushing notifications successfully, however, the API doesn't seem to pass in the WLPushOptions object that I'm using.

The call in my obj c code:

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.");

The log:

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

Then, in the HSQL db log (using the local Worklight Developer client):

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

I've X'ed out the app and subscription id.

As you can see in the INSERT statement, the fifth field (the OPTIONS field in the NOTIFICATION_DEVICE table), is inserting an empty JSON object, where I passed in the key "param3" and value "Testing3", so, I would expect it to be:

{'param3':'Testing3'}

This seems to be what the the native iOS API docs expect (NSString parameters) to the addSubscriptionParameter method. I'm very new to Objective C, but, this looks correct to me.

Anyone know what I'm doing wrong?

Was it helpful?

Solution

This is a defect and has been logged. Fortunately there is an easy workaround:

WLPushOptions *options = [WLPushOptions new];
options.parameters = [NSMutableDictionary new];
[options addSubscriptionParameter:@"param3" :@"Testing3"];
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top