LoginSignup
5
4

More than 5 years have passed since last update.

Crashlyticsへ追加情報も送信しよう

Posted at

Crashlyticsは入れておくだけでクラッシュ時のコールスタックが表示されるので調査に便利
また追加情報も送信できる仕組みもある。

1. ユーザ情報を送る

#import <Crashlytics/Crashlytics.h>

- (void)testMethod2
{
    [[Crashlytics sharedInstance] setUserEmail:@"user@email.com"];
    [[Crashlytics sharedInstance] setUserIdentifier:@"12344556789"];
    [[Crashlytics sharedInstance] setUserName:@"test user"];

    [[Crashlytics sharedInstance] crash];
}
  • 結果

スクリーンショット 2015-11-23 10.41.14.png

2. Key,Valueで送る

- (void)testMethod2
{
    [[Crashlytics sharedInstance] setBoolValue:YES forKey:@"boolLog"];
    [[Crashlytics sharedInstance] setFloatValue:0.12345 forKey:@"floatLog"];
    [[Crashlytics sharedInstance] setIntValue:3 forKey:@"intLog"];
    [[Crashlytics sharedInstance] setObjectValue:@"objectValue..test" forKey:@"objectLog"];

    [[Crashlytics sharedInstance] crash];
}
  • 結果

スクリーンショット 2015-11-23 10.41.49.png

3. ログ情報を送る

- (void)testMethod2
{
    CLS_LOG(@"CLS_LOG for Dict %@", @{@"key1":@"value1", @"key2":@"value2", @"key3":@"value3"});

    [[Crashlytics sharedInstance] crash];
}
  • 結果

スクリーンショット 2015-11-23 10.42.04.png

4. NSException以外のカスタム例外を送る

- (void)testMethod2
{
    [[Crashlytics sharedInstance] recordCustomExceptionName:@"customEx..." reason:@"custom_reason.." frameArray:@[[CLSStackFrame stackFrameWithAddress:1234567]]];

    [[Crashlytics sharedInstance] crash];
}
  • 結果

スクリーンショット 2015-11-23 10.42.18.png

参考:
http://support.crashlytics.com/knowledgebase/articles/92519-how-do-i-use-logging-
http://support.crashlytics.com/knowledgebase/articles/92520-how-do-i-use-custom-keys-
http://support.crashlytics.com/knowledgebase/articles/92521-how-do-i-set-user-information-

5
4
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
4