UAJavaScriptEnvironment

Objective-C


@interface UAJavaScriptEnvironment : NSObject

Swift

class UAJavaScriptEnvironment : NSObject

The JavaScript environment builder that is used by the native bridge.

JavaScript Environment Methods

  • Factory method to create the JavaScript environment with the default appKey, deviceId, channel, and named user getters already defined.

    Declaration

    Objective-C

    + (nonnull instancetype)defaultEnvironment;

    Swift

    class func `default`() -> Self

    Return Value

    The default JavaScript environment.

  • Adds a getter to the UAirship JavaScript instance.

    Declaration

    Objective-C

    - (void)addStringGetter:(nonnull NSString *)methodName
                      value:(nullable NSString *)value;

    Swift

    func addStringGetter(_ methodName: String, value: String?)

    Parameters

    methodName

    The getter’s name.

    value

    The getter’s value.

  • Adds a getter to the UAirship JavaScript instance.

    Declaration

    Objective-C

    - (void)addNumberGetter:(nonnull NSString *)methodName
                      value:(nullable NSNumber *)value;

    Swift

    func addNumberGetter(_ methodName: String, value: NSNumber?)

    Parameters

    methodName

    The getter’s name.

    value

    The getter’s value. A nil value will return -1 in the JavaScript environment.

  • Adds a getter to the UAirship JavaScript instance.

    Declaration

    Objective-C

    - (void)addDictionaryGetter:(nonnull NSString *)methodName
                          value:(nullable NSDictionary *)value;

    Swift

    func addDictionaryGetter(_ methodName: String, value: [AnyHashable : Any]?)

    Parameters

    methodName

    The getter’s name.

    value

    The getter’s value.

  • Builds the script that can be injected into a web view.

    Declaration

    Objective-C

    - (nonnull NSString *)build;

    Swift

    func build() -> String

    Return Value

    The script.