Skip to content
This repository has been archived by the owner on Aug 2, 2023. It is now read-only.

Commit

Permalink
Merge pull request #127 from bmourat/fix/update-docs
Browse files Browse the repository at this point in the history
Code samples in swift added to docs
  • Loading branch information
Benjamin Scholtysik (Reimold) authored Sep 14, 2017
2 parents dce74c3 + 059909c commit a01d95a
Showing 1 changed file with 92 additions and 40 deletions.
132 changes: 92 additions & 40 deletions Documentation/Guides/Installation & Setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,32 +91,32 @@ From our experience, 3rd-party libraries usually reside inside a subdirectory (l
1. Open your `AppDelegate.m` file.
2. Add the following line at the top of the file below your own `import` statements:

```
```objc
@import HockeySDK;
```

3. Search for the method `applicationDidFinishLaunching:`
4. Add the following lines to setup and start the Application Insights SDK:

```
```objc
[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];
// Do some additional configuration if needed here
[[BITHockeyManager sharedHockeyManager] startManager];
```
**Swift 3**
**Swift**
1. Open your `AppDelegate.swift` file.
2. Add the following line at the top of the file below your own import statements:
```
```swift
import HockeySDK
```

3. Search for the method `applicationWillFinishLaunching`
4. Add the following lines to setup and start the Application Insights SDK:

```
```swift
BITHockeyManager.shared().configure(withIdentifier: "APP_IDENTIFIER")
// Do some additional configuration if needed here
BITHockeyManager.shared().start()
Expand Down Expand Up @@ -157,17 +157,17 @@ This feature can be disabled as follows:

**Objective-C**

```
```objc
[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];

[[BITHockeyManager sharedHockeyManager] setDisableCrashManager: YES]; //disable crash reporting

[[BITHockeyManager sharedHockeyManager] startManager];
```
**Swift 3**
**Swift**
```
```swift
BITHockeyManager.shared().configure(withIdentifier: "APP_IDENTIFIER")
BITHockeyManager.shared().isCrashManagerDisabled = true
Expand All @@ -181,17 +181,17 @@ Crashes are send the next time the app starts. If `crashManagerStatus` is set to

**Objective-C**

```
```objc
[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];

[[BITHockeyManager sharedHockeyManager].crashManager setAutoSubmitCrashReport: YES];

[[BITHockeyManager sharedHockeyManager] startManager];
```
**Swift 3**
**Swift**
```
```swift
BITHockeyManager.shared().configure(withIdentifier: "APP_IDENTIFIER")
BITHockeyManager.shared().crashManager.isAutoSubmitCrashReport = true
Expand All @@ -211,7 +211,7 @@ On Mac OS X there are three types of crashes that are not reported to a register
1. Custom `NSUncaughtExceptionHandler` don't start working until after `NSApplication` has finished calling all of its delegate methods!
Example:

```
```objc
- (void)applicationDidFinishLaunching:(NSNotification *)note {
...
[NSException raise:@"ExceptionAtStartup" format:@"This will not be recognized!"];
Expand All @@ -222,7 +222,7 @@ Example:
2. The default `NSUncaughtExceptionHandler` in `NSApplication` only logs exceptions to the console and ends their processing. Resulting in exceptions that occur in the `NSApplication` "scope" not occurring in a registered custom `NSUncaughtExceptionHandler`.
Example:

```
```objc
- (void)applicationDidFinishLaunching:(NSNotification *)note {
...
[self performSelector:@selector(delayedException) withObject:nil afterDelay:5];
Expand All @@ -238,7 +238,7 @@ NSArray *array = [NSArray array];
3. Any exceptions occurring in IBAction or other GUI does not even reach the NSApplication default UncaughtExceptionHandler.
Example:

```
```objc
- (IBAction)doExceptionCrash:(id)sender {
NSArray *array = [NSArray array];
[array objectAtIndex:23];
Expand All @@ -261,31 +261,73 @@ Alternatively, if you have your own NSApplication subclass, change it to be a su

The `BITHockeyManagerDelegate` protocol provides methods to add additional data to a crash report:

1. UserID: `- (NSString *)userIDForHockeyManager:(BITHockeyManager *)hockeyManager componentManager:(BITHockeyBaseManager *)componentManager;`
2. UserName: `- (NSString *)userNameForHockeyManager:(BITHockeyManager *)hockeyManager componentManager:(BITHockeyBaseManager *)componentManager;`
3. UserEmail: `- (NSString *)userEmailForHockeyManager:(BITHockeyManager *)hockeyManager componentManager:(BITHockeyBaseManager *)componentManager;`
1. UserID:

**Objective-C**

`- (NSString *)userIDForHockeyManager:(BITHockeyManager *)hockeyManager componentManager:(BITHockeyBaseManager *)componentManager;`

**Swift**

`optional public func userID(for hockeyManager: BITHockeyManager!, componentManager: BITHockeyBaseManager!) -> String!`

2. UserName:

**Objective-C**

`- (NSString *)userNameForHockeyManager:(BITHockeyManager *)hockeyManager componentManager:(BITHockeyBaseManager *)componentManager;`

**Swift**

`optional public func userName(for hockeyManager: BITHockeyManager!, componentManager: BITHockeyBaseManager!) -> String!`

3. UserEmail:

**Objective-C**

`- (NSString *)userEmailForHockeyManager:(BITHockeyManager *)hockeyManager componentManager:(BITHockeyBaseManager *)componentManager;`

**Swift**

`optional public func userEmail(for hockeyManager: BITHockeyManager!, componentManager: BITHockeyBaseManager!) -> String!`

The `BITCrashManagerDelegate` protocol (which is automatically included in `BITHockeyManagerDelegate`) provides methods to add more crash specific data to a crash report:

1. Text attachments: `-(NSString *)applicationLogForCrashManager:(BITCrashManager *)crashManager`
1. Text attachments:

**Objective-C**

`-(NSString *)applicationLogForCrashManager:(BITCrashManager *)crashManager`

**Swift**

`optional public func applicationLog(for crashManager: BITCrashManager!) -> String!`

Check the following tutorial for an example on how to add CocoaLumberjack log data: [How to Add Application Specific Log Data on iOS or OS X](http://support.hockeyapp.net/kb/client-integration-ios-mac-os-x/how-to-add-application-specific-log-data-on-ios-or-os-x)

2. Binary attachments: `-(BITHockeyAttachment *)attachmentForCrashManager:(BITCrashManager *)crashManager`
2. Binary attachments:

**Objective-C**

`-(BITHockeyAttachment *)attachmentForCrashManager:(BITCrashManager *)crashManager`

**Swift**

`optional public func attachment(for crashManager: BITCrashManager!) -> BITHockeyAttachment!`

Make sure to implement the protocol

**Objective-C**

```
```objc
@interface YourAppDelegate () <BITHockeyManagerDelegate> {}

@end
```

**Swift 3**
**Swift**

```
```swift
class YourAppDelegate: NSObject, BITHockeyManagerDelegate {

}
Expand All @@ -295,17 +337,17 @@ and set the delegate:

**Objective-C**

```
```objc
[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];

[[BITHockeyManager sharedHockeyManager] setDelegate: self];

[[BITHockeyManager sharedHockeyManager] startManager];
```
**Swift 3**
**Swift**
```
```swift
BITHockeyManager.shared().configure(withIdentifier: "APP_IDENTIFIER")
BITHockeyManager.shared().delegate = self
Expand All @@ -326,13 +368,13 @@ Just in case you want to opt-out of the automatic collection of anonymous users

**Objective-C**

```
```objc
[BITHockeyManager sharedHockeyManager].disableMetricsManager = YES;
```

**Swift 3**
**Swift**

```
```swift
BITHockeyManager.shared().isMetricsManagerDisabled = true
```

Expand All @@ -345,15 +387,15 @@ By tracking custom events, you can now get insight into how your customers use y

**Objective-C**

```
```objc
BITMetricsManager *metricsManager = [BITHockeyManager sharedHockeyManager].metricsManager;

[metricsManager trackEventWithName:eventName]
```
**Swift 3**
**Swift**
```
```swift
let metricsManager = BITHockeyManager.shared().metricsManager
metricsManager.trackEvent(withName: eventName)
Expand All @@ -374,7 +416,7 @@ It's possible to attach porperties and/or measurements to a custom event.

**Objective-C**

```
```objc
BITMetricsManager *metricsManager = [BITHockeyManager sharedHockeyManager].metricsManager;

NSDictionary *myProperties = @{@"Property 1" : @"Something",
Expand All @@ -387,9 +429,9 @@ NSDictionary *myMeasurements = @{@"Measurement 1" : @1,
[metricsManager trackEventWithName:eventName properties:myProperties measurements:myMeasurements]
```
**Swift 3**
**Swift**
```
```swift
let myProperties = ["Property 1": "Something", "Property 2": "Other thing", "Property 3" : "Totally different thing."]
let myMeasurements = ["Measurement 1": 1, "Measurement 2": 2.3, "Measurement 3" : 30000]
Expand All @@ -406,13 +448,13 @@ You should never create your own instance of `BITFeedbackManager` but use the on

**Objective-C**

```
```objc
[BITHockeyManager sharedHockeyManager].feedbackManager
```

**Swift 3**
**Swift**

```
```swift
BITHockeyManager.shared().feedbackManager
```

Expand Down Expand Up @@ -442,7 +484,7 @@ sparkleUpdater.sendsSystemProfile = YES;

2. Add the following Sparkle delegate method (don't forget to bind `SUUpdater` to your appDelegate!):

```
```objc
- (NSArray *)feedParametersForUpdater:(SUUpdater *)updater
sendingSystemProfile:(BOOL)sendingProfile {
return [[BITSystemProfile sharedSystemProfile] systemUsageData];
Expand All @@ -453,7 +495,7 @@ return [[BITSystemProfile sharedSystemProfile] systemUsageData];

One example scenario is when the app is started or comes to foreground and when it goes to background or is terminated:

```
```objc
- (void)applicationWillFinishLaunching:(NSNotification *)aNotification
NSNotificationCenter *dnc = [NSNotificationCenter defaultCenter];
Expand All @@ -470,14 +512,24 @@ BITSystemProfile *bsp = [BITSystemProfile sharedSystemProfile];
To check if data is send properly to HockeyApp and also see some additional SDK debug log data in the console, add the following line before `startManager`:
```
**Objective-C**
```objc
[[BITHockeyManager sharedHockeyManager] configureWithIdentifier:@"APP_IDENTIFIER"];
[BITHockeyManager sharedHockeyManager].logLevel = BITLogLevelDebug;
[[BITHockeyManager sharedHockeyManager] startManager];
```

**Swift**

```swift
BITHockeyManager.shared().configure(withIdentifier: "APP_IDENTIFIER")
BITHockeyManager.shared().logLevel = BITLogLevel.debug
BITHockeyManager.shared().start()
```

<a id="documentation"></a>
## 4. Documentation

Expand Down

0 comments on commit a01d95a

Please sign in to comment.