• Log in

setAttribute (iOS SDK API)

Syntax

setAttribute:(NSString*)name value:(id) value;
NewRelic.setAttribute(string $name, string or float $value)

Creates a session-level attribute shared by multiple mobile monitoring event types. Overwrites its previous value and type each time it is called.

Requirements

Compatible with all agent versions.

Description

This static method creates a session-level custom attribute with a specified name and value. When called, it overwrites its previous value and type. The created attribute is shared by multiple Mobile monitoring event types.

For more context on how to use this, see the iOS API guide.

You can override any of the MobileSession default attributes except:

  • appId
  • appName
  • accountId
  • carrier
  • category
  • deviceManufacturer
  • deviceModel
  • eventType
  • install
  • lastInteraction
  • memUsageMb
  • newRelicVersion
  • osMajorVersion
  • osName
  • osVersion
  • platform
  • platformVersion
  • sessionDuration
  • sessionId
  • timestamp
  • type
  • upgradeFrom
  • uuid
  • Anything prefixed with NewRelic

For context on how to use this API, see the documentation about sending custom attributes and events:

Parameters

Parameter

Description

$name

string

Required. Name of the session attribute.

$value

string or float

Required. The second parameter passed can be either a string value or a float value.

Return values

Returns true if recorded successfully, and false if it doesn't.

Examples

Objective-C

Method:

+ (BOOL) setAttribute:(NSString*)name value:(id) value;

Examples:

BOOL attributeSet = [NewRelic setAttribute:@"buildConfiguration" value:@"AppStore-release"];
BOOL attributeSet = [NewRelic setAttribute:@"rate" value:@9999.99];

Swift

Method:

NewRelic.setAttribute(name: String!, value: AnyObject!>) -> Bool

Examples:

var attributeSet = NewRelic.setAttribute("buildConfiguration", value: "AppStore-release")
attributeSet = NewRelic.setAttribute("rate", value: 9999.99)
Copyright © 2022 New Relic Inc.

This site is protected by reCAPTCHA and the Google Privacy Policy and Terms of Service apply.