|
| 1 | +// |
| 2 | +// LPCrashHandler.h |
| 3 | +// Leanplum iOS SDK Version 2.0.6 |
| 4 | +// |
| 5 | +// Copyright (c) 2018 Leanplum, Inc. All rights reserved. |
| 6 | +// |
| 7 | +// Licensed to the Apache Software Foundation (ASF) under one |
| 8 | +// or more contributor license agreements. See the NOTICE file |
| 9 | +// distributed with this work for additional information |
| 10 | +// regarding copyright ownership. The ASF licenses this file |
| 11 | +// to you under the Apache License, Version 2.0 (the "License"); |
| 12 | +// you may not use this file except in compliance with the License. |
| 13 | +// You may obtain a copy of the License at |
| 14 | +// |
| 15 | +// http://www.apache.org/licenses/LICENSE-2.0 |
| 16 | +// |
| 17 | +// Unless required by applicable law or agreed to in writing, |
| 18 | +// software distributed under the License is distributed on an |
| 19 | +// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 20 | +// KIND, either express or implied. See the License for the |
| 21 | +// specific language governing permissions and limitations |
| 22 | +// under the License. |
| 23 | + |
| 24 | +#import "LPCrashHandler.h" |
| 25 | + |
| 26 | +@interface LPCrashHandler() |
| 27 | + |
| 28 | +@property (nonatomic, strong) id<LPCrashReporting> crashReporter; |
| 29 | + |
| 30 | +@end |
| 31 | + |
| 32 | +@implementation LPCrashHandler |
| 33 | + |
| 34 | ++(instancetype)sharedCrashHandler |
| 35 | +{ |
| 36 | + static LPCrashHandler *sharedCrashHandler = nil; |
| 37 | + @synchronized(self) { |
| 38 | + if (!sharedCrashHandler) { |
| 39 | + sharedCrashHandler = [[self alloc] init]; |
| 40 | + } |
| 41 | + } |
| 42 | + return sharedCrashHandler; |
| 43 | +} |
| 44 | + |
| 45 | +-(instancetype)init |
| 46 | +{ |
| 47 | + self = [super init]; |
| 48 | + if (self) { |
| 49 | + [self initializeLeanplumReporter]; |
| 50 | + } |
| 51 | + return self; |
| 52 | +} |
| 53 | + |
| 54 | +-(void)initializeLeanplumReporter |
| 55 | +{ |
| 56 | + Class LPCrashReporterClass = NSClassFromString(@"LPCrashReporter"); |
| 57 | + if (LPCrashReporterClass) { |
| 58 | + _crashReporter = [[LPCrashReporterClass alloc] init]; |
| 59 | + } |
| 60 | +} |
| 61 | + |
| 62 | +-(void)reportException:(NSException *)exception |
| 63 | +{ |
| 64 | + if (self.crashReporter) { |
| 65 | + [self.crashReporter reportException:exception]; |
| 66 | + } |
| 67 | +} |
| 68 | + |
| 69 | +@end |
0 commit comments