WLActionReceiver无法在MobileFirst 8上运行

时间:2017-01-10 09:39:50

标签: cordova ibm-mobilefirst

我正在基于Cordova的MobileFirst 8应用程序中实现WLActionReceiver协议。

我正在尝试将操作从Javascript发送到Native(目标c),但未收到操作或未调用onActionReceived方法。

我将此代码实现到wlInitDidCompleteSuccessfully方法中以设置ActionReceiver。

[[WL sharedInstance] addActionReceiver:[[ActionReceiver alloc] init]];

这是ActionReceiver代码:

ActionReceiver.h

#import <Foundation/Foundation.h>
#import <IBMMobileFirstPlatformFoundationHybrid/WLActionReceiver.h>

@interface ActionReceiver : NSObject<WLActionReceiver>
@end

ActionReceiver.m

#import "ActionReceiver.h"

@implementation ActionReceiver

- (void)onActionReceived:(NSString *)action withData:(NSDictionary *)data {
    NSLog(@"onActionReceived");
}

我正在使用此代码从Javascript发送操作:

var data = {someproperty:1234};
WL.App.sendActionToNative("DeviceID", data);

有人可以帮助我吗?

谢谢

1 个答案:

答案 0 :(得分:0)

这似乎是一个设置问题,因为执行以下操作可以解决问题:

cordova platform remove ios
cordova platform add ios