Help us understand the problem. What is going on with this article?

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

More than 5 years have passed since last update.

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-

gunosy
情報キュレーションサービス「グノシー」や「ニュースパス」の開発・運営を通じて、情報を世界の人に最適に届けていきます。
http://gunosy.com
Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away