Home » Javascript » Pass Javascript Var to Objective C var

Pass Javascript Var to Objective C var

Posted by: admin October 29, 2018 Leave a comment


I’m trying to get a value from a Javascript Variable and set that value into an objective-c variable, i really know almost nothing about objective-c, and i’m playing around with what i see…

The reason i need this is because i want a send a tag to OneSignal from my webview app alongside with the player_id so far this is what i have:



   var uuID = '{{ $uuID }}';


Objective C:

@implementation AppDelegate

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
    [UIApplication sharedApplication].statusBarStyle = UIStatusBarStyleLightContent;

    //In App purchases
    if ([IN_APP_PRODUCT length] > 0){
        [WBInAppHelper setProductsList:@[IN_APP_PRODUCT]];

    [iRate sharedInstance].usesUntilPrompt = 5;

    [self loadHTTPCookies];

    // Navbar appearance
    [[UINavigationBar appearance] setTitleTextAttributes:[NSDictionary dictionaryWithObjectsAndKeys:[UIColor whiteColor],NSForegroundColorAttributeName, nil]];

    // OneSignal/Notifications
    if ([ONESIGNAL_APP_ID length] > 0){
        self.oneSignal = [OneSignal initWithLaunchOptions:launchOptions appId:ONESIGNAL_APP_ID];
        [OneSignal sendTags:@{@"njID" : @"1"}]; //Here i want to send the var from javascript which contains the value to send to onesignal
        [OneSignal promptLocation];

    return YES;

I have no idea how to achieve this, i have tried to follow some other questions related, but just don’t understand where and what to do, thanks in advance.