1. Install the Raygun4iOS provider
If you're using the CocoaPods package manager, add the following line to the appropriate target(s) within your Podfile.
Then, open a shell, navigate to the location of your project's Podfile and run:
If you're not using CocoaPods, the Raygun4iOS Pulse provider can be downloaded here. Unzip, and copy the Raygun4iOS.framework file into a folder in your project. In XCode, select your project, and then click the project target. Navigate to the 'Build Phases' tab and add the Raygun4iOS.framework to the 'Link Binary With Libraries' list.
2. Enable Pulse in your app
Add the following code to the start of the didFinishLaunchingWithOptions function of your app delegate. Your app API key is displayed when you create a new application in your Raygun account, or when you unlock Pulse for an existing app, or can be viewed in the "Application settings".
[[Raygun sharedReporterWithApiKey:@"YOUR_APP_API_KEY"] attachPulse];
Note that the above code will also enable Raygun crash reporting in your app. If you only want Pulse for now, use the "withCrashReporting:false" function overload.
If you wish to use Pulse without network performance logging, use the code below.
[[Raygun sharedReporterWithApiKey:@"YOUR_APP_API_KEY"] attachPulseWithNetworkLogging:false];
3. Provide a user identifier
By default, each user will be identified with a unique guid. If possible, we highly recommend providing your own unique identifiers for your users which can be done as follows. The identifier string can be any unique user id you want - email address is just a recommended example.
[[Raygun sharedReporter] identifyWithUserInfo:[[RaygunUserInfo alloc]
Pulse messages will be sent to Raygun as soon as the app starts up. So once you've set up Pulse in your app, run it up and go to your Pulse dashboard to see the data it collects. Of course Pulse is most valuable once your app is out there in the store.
If building your project produces compile time errors along the lines of "Undefined symbols for architecture x86_64", you'll need to add a linker flag. To do this, click your project in Xcode, and then select your main app target. Go to the "Build Settings" tab, search for "Other Linker Flags" and add -lc++ to this option and you'll be good to go.
Pulse will automatically record information about views when attached. You can filter out the reporting of view information by view name.
[[Raygun sharedReporter] ignoreViews:[[NSArray alloc]initWithObjects:@"RootViewController", nil]];
Once Pulse is enabled, Raygun4iOS will automatically log the performance of network calls made with the following methods.
- [NSURLSession dataTaskWithURL:]
- [NSURLSession dataTaskWithURL:completionHandler:]
- [NSURLSession dataTaskWithRequest:]
- [NSURLSession dataTaskWithRequest:completionHandler:]
- [NSURLSession downloadTaskWithURL:]
- [NSURLSession downloadTaskWithURL:completionHandler:]
- [NSURLSession downloadTaskWithRequest:]
- [NSURLSession downloadTaskWithRequest:completionHandler:]
- [NSURLSession uploadTaskWithRequest:fromData:]
- [NSURLSession uploadTaskWithRequest:fromData:completionHandler:]
- [NSURLSession uploadTaskWithRequest:fromFile:]
- [NSURLSession uploadTaskWithRequest:fromFile:completionHandler:]
- [NSURLConnection sendAsynchronousRequest:queue:completionHandler]
- [NSURLConnection sendSynchronousRequest:returningResponse:error:]
You can also send network call timings to Raygun manually using the following Raygun4iOS API.
[[Raygun sharedReporter] sendPulseTimingEvent:NetworkCall withName:@"GET https://raygun.com" withDuration:1234];
The first parameter is the event type, which can currently be NetworkCall or ViewLoaded. The name string can be whatever works best for you - for network calls, the HTTP method and url is a recommended example. The duration is the milliseconds that you've measured the network call to take.
Details about all automatically and manually logged network calls can be found on the Performance tab of your Pulse for mobile dashboard.
Filtering network calls
If you don’t wish the performance of certain network requests to be logged, you can filter them out by URL.
[[Raygun sharedReporter] ignoreURLs:[[NSArray alloc]initWithObjects:@"raygun.com", nil]];