我发布了我的iOS应用程序的更新,AFAIK并没有改变我们处理推送通知的方式。
然而,我们的一部分用户报告发布时系统崩溃。 Fabric告诉我应用程序崩溃的原因是:
Fatal Exception: NSInternalInconsistencyException
Operation is invalid after previous operation.
并显示我在方法updateAgenciesChannels:
中将用户设置为默认推送频道时发生的情况NSArray *agencies = [NSArray arrayWithObjects:@"channelA",@"channelB", nil];
NSUserDefaults *defaults = [NSUserDefaults standardUserDefaults];
PFInstallation *currentInstallation = [PFInstallation currentInstallation];
for(NSString *agency in agencies)
{
NSString *agencyString = [@"a-" stringByAppendingString:agency];
BOOL agencyState = [defaults boolForKey:agencyString];
if(agencyState)
[currentInstallation addUniqueObject:agencyString
forKey:@"channels"];
else
[currentInstallation removeObject:agencyString
forKey:@"channels"];
[currentInstallation saveInBackground];
}
它似乎与iOS版本无关(所有崩溃都发生在9.1.3上,但9.1.3上的很多用户都很好),它似乎也与设备类型无关
对于此用户子集,即使在再次删除/安装应用程序之后,崩溃仍然是系统化的,
以下是完整崩溃日志之一:
Fatal Exception: NSInternalInconsistencyException
0 CoreFoundation 0x180ffee38 __exceptionPreprocess
1 libobjc.A.dylib 0x180663f80 objc_exception_throw
2 CoreFoundation 0x180ffed80 -[NSException initWithCoder:]
3 NextRide 0x1001c012c -[PFAddUniqueOperation mergeWithPrevious:] (PFFieldOperation.m:277)
4 NextRide 0x1001e1240 -[PFObject(Private) performOperation:forKey:] (PFObject.m:1172)
5 NextRide 0x1001e83dc -[PFObject addUniqueObjectsFromArray:forKey:] (PFObject.m:2170)
6 NextRide 0x1001e8318 -[PFObject addUniqueObject:forKey:] (PFObject.m:2166)
7 NextRide 0x1000ac4c8 +[NRNPush updateAgenciesChannels] (NRNPush.m:54)
8 NextRide 0x1000ac2dc +[NRNPush updateDefaultChannels] (NRNPush.m:35)
9 NextRide 0x100083b10 -[AppDelegate application:didFinishLaunchingWithOptions:] (AppDelegate.m:86)
10 UIKit 0x1861be8a8 -[UIApplication _handleDelegateCallbacksWithOptions:isSuspended:restoreState:]
11 UIKit 0x1863ee094 -[UIApplication _callInitializationDelegatesForMainScene:transitionContext:]
12 UIKit 0x1863f2500 -[UIApplication _runWithMainScene:transitionContext:completion:]
13 UIKit 0x1863ef674 -[UIApplication workspaceDidEndTransaction:]
14 FrontBoardServices 0x18299f7ac __FBSSERIALQUEUE_IS_CALLING_OUT_TO_A_BLOCK__
15 FrontBoardServices 0x18299f618 -[FBSSerialQueue _performNext]
16 FrontBoardServices 0x18299f9c8 -[FBSSerialQueue _performNextFromRunLoopSource]
17 CoreFoundation 0x180fb5124 __CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION__
18 CoreFoundation 0x180fb4bb8 __CFRunLoopDoSources0
19 CoreFoundation 0x180fb28b8 __CFRunLoopRun
20 CoreFoundation 0x180edcd10 CFRunLoopRunSpecific
21 UIKit 0x1861b7834 -[UIApplication _run]
22 UIKit 0x1861b1f70 UIApplicationMain
23 NextRide 0x1000d054c main (main.m:28)
24 libdispatch.dylib 0x180a7a8b8 (Missing)
答案 0 :(得分:0)
事实证明,当多次调用此方法时,我可能会尝试将用户置于某个频道,如果他已经被禁用("唯一对象"已经在数组中),并试图取消注意如果用户已经没有被捕获(删除不在数组中的对象)