Native registration to Azure hub always crashes the first time the app is launched - ios

I've made a iOS 7.0 app that use push-notifications and the Azure Mobile services framework. All is good, but I've seen that when I clear my app (e.g., remove it from my phone to force a "first launch" use-case), the app crashes from what I assume is a bug/crash within the Azure framework?
Basically, I'm running the following code-snippet;
//Proceed and register
SBNotificationHub* hub = [[SBNotificationHub alloc] initWithConnectionString:notificationConnectionString
notificationHubPath:notificationHub];
DDLogInfo(#"Hub object = %#", hub);
//Register with native hub...
NSError* error = nil;
if (![hub registerNativeWithDeviceToken:deviceToken tags:nil error:&error])
{
//False
DDLogInfo(#"Failed to register with native hub...");
if (error)
DDLogError(#"Found error; %#", error.localizedDescription);
}
... and when registerNativeWithDeviceToken: is executed, my app crashes with the following exception;
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil'
Enabling breakpoint exceptions show the following trace, indicating that it's the SBLocalStorage class, part of the Azure framework, that try to put nil in a NSDictionary;
Thread 4, Queue : NSManagedObjectContext Queue
#0 0x3bc7e1f0 in __pthread_kill ()
#9 0x30e6e1be in -[__NSDictionaryM setObject:forKey:] ()
#10 0x0022afa8 in -[SBLocalStorage updateWithRegistrationName:registration:] at /Users/admin/Desktop/Main/enlist/WindowsAzureMessaging/WindowsAzureMessaging/Helpers/SBLocalStorage.m:89
#11 0x0022ae4c in -[SBLocalStorage updateWithRegistration:] at /Users/admin/Desktop/Main/enlist/WindowsAzureMessaging/WindowsAzureMessaging/Helpers/SBLocalStorage.m:70
#12 0x00227d76 in -[SBNotificationHub retrieveAllRegistrationsWithDeviceToken:error:] at /Users/admin/Desktop/Main/enlist/WindowsAzureMessaging/WindowsAzureMessaging/SBNotificationHub.m:700
#13 0x00227202 in -[SBNotificationHub registerNativeWithDeviceToken:tags:error:] at /Users/admin/Desktop/Main/enlist/WindowsAzureMessaging/WindowsAzureMessaging/SBNotificationHub.m:458
#14 0x000b6788 in -[BackendCommunicator registerPushNotificationsForDeviceToken:] at /Users/markus/Xcode/MyApp/myApp/BackendCommunicator.m:1632
But, regardless, has anyone else seen this? And moreover, why does it work all consecutive launches, BUT NOT the first?
Best,
/Markus

I tried to reproduce the issue you described, but for me SDK works OK at this scenario. However I found and fixed serious bug.
Latest version is available on Git Hub, I've also uploaded ready-to-use binaries for your convenience: https://github.com/Azure/azure-notificationhubs/tree/master/iOS/bin.
So I would suggest you to try if it works after last fixes.

Related

Flutter: Firestore transaction crashes only on physical iOS device

I have a simple transaction that updates a Firestore document. It works correctly on Android devices, Android Emulators and iOS emulators, but crashes on a physical iOS device:
Firestore.instance.runTransaction((Transaction tx) async {
DocumentSnapshot docSnapshot = await tx.get(docRef);
tx.update(
docRef,
{
'title':'A Title'
},
);
}
Error:
-[NSError init] called; this results in an invalid NSError instance. It will raise an exception in a future release. Please call
errorWithDomain:code:userInfo: or initWithDomain:code:userInfo:. This
message shown only once.
Assertion failure in void
firebase::firestore::core::Transaction::EnsureCommitNotCalled()(),
/Users/path_to_app/ios/Pods/FirebaseFirestore/Firestore/core/src/firebase/firestore/core/transaction.mm:198
*** Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'FIRESTORE INTERNAL
ASSERTION FAILED: A transaction object cannot be used after its update
callback has been invoked. (expected !committed_)'
I'm not sure what the error means, and my Google quest has hit a dead-end. Really hoping someone can point out what the problem might be!

Firebase database iOS crashing GTMSessionFetcher

I updated firebase and since then my app keeps crashing with the following error
Fetcher delegate class: NRMAURLSessionTaskDelegate Fetcher made an
extra session: GTMSessionFetcher 0x125d53db0 Couldn't assign
delegate.
Fetcher delegate class: NRMAURLSessionTaskDelegate
-[GTMSessionFetcher setFetcher:forTask:]: unrecognized selector sent to instance 0x125d53db0
* Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[GTMSessionFetcher
setFetcher:forTask:]: unrecognized selector sent to instance
0x125d53db0'
* First throw call stack: (0x18260ad8c 0x1817c45ec 0x182618098 0x1826105c8 0x1824f641c 0x104637b14 0x104613928 0x10461011c
0x102d9364c 0x102d96bdc 0x102d95140 0x102d92a54 0x102db3f90
0x102db36b0 0x102da0e00 0x105bfd1dc 0x105bfd19c 0x105c0bdfc
0x105c006ac 0x105c0bc20 0x105c006ac 0x105c0cd54 0x105c13e38
0x18222fe70 0x18222fb08) libc++abi.dylib: terminating with uncaught
exception of type NSException
the call that I make and crashes is the following:
let reviewsRef = Database.database().reference()
reviewsRef.child("reviews").queryOrdered(byChild: "timestamp").queryLimited(toLast: count)
I added a debug log and the call is made only once.
It seems the line that the app is crashing is
let ref = Database.database().reference()
Did anything changed regarding configuring Firebase from 4.9 to 5.0 version?
Another update:
It seems to be working on the Xcode simulator but not on device. Device is iPhone 6s with 11.4
Kind of working since on simulator I receive the whole database instead of only the "reviews" that I am requesting
if the rules are:
{
"rules": {
".read": true,
but when I change to:
"rules": {
"reviews": {
".read": true,
I get permission denied(on simulator).It has to do maybe with authentication? I understand that those 2 might be two different issues.
I have no idea why this happened on the first place. But I created a new project in firebase with exact same rules and it worked... for some reason the specific project became corrupt on firebase side.
NRMAURLSessionTaskDelegate indicates usage of New Relic - if it worked on a clean project there might be an incompatibility with Firebase

IOS Google OAuth error occured after 1 success authentication

I was trying to make a Google authentication with swift to get message list. However i follow all steps in Google here
after i run in simulator and success logging in to my account authentication was successful. then problem appears after all success which is weird. does any knows how to fix this?
selector "displayResultWithTicket:finishedWithObject:error:" is unimplemented or misnamed
Assertion failure in void GTMSessionFetcherAssertValidSelector(id _Nullable __strong, SEL _Nullable, ...)(), /Users/macbookpro/Documents/Zaiya/Pods/GTMSessionFetcher/Source/GTMSessionFetcher.m
Terminating app due to uncaught exception 'NSInternalInconsistencyException', reason: 'callback selector unimplemented or misnamed'
please share your knowledge, thanks!
actual run error:
I ran into the same problem. I believe it's because Google hasn't updated the Quickstart for Swift 3 yet.
Change:
displayResultWithTicket:finishedWithObject:error: to #selector([Your View Controller Name Here].displayResultWithTicket(ticket:finishedWithObject:error:)), which is in line with the new Swift 3 syntax

iOS 64bit #try {... } #catch {...} not working

I have a very peculiar issue.
Recently I added 64bit support to my iOS project (arm64), ever since doing that I started receiving uncaught exceptions for segments of my code inside #try...#catch (I'm using Crashlytics for crash reporting). I managed to reproduce the problem with the following lines of code anywhere in my app (I wrote them inside init of one of my view controllers):
#try {
NSMutableDictionary *m = [[NSMutableDictionary alloc] init];
NSString *s;
m[s] = #"poop";
} #catch (NSException *e) {
NSLog(#"POOP");
}
The exception gets caught by the UncaughtExceptionHandler instead of the #catch clause. I'm confused as to what can cause this. The output in the console:
2015-02-22 19:19:53.525 [391:30650] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** setObjectForKey: key cannot be nil'
*** First throw call stack:
(0x18823a59c 0x1989400e4 0x1881251f8 0x10011e2f4 0x10011e068 0x10010e480 0x10010db78 0x10010d944 0x1000a8050 0x100075d88 0x100075160 0x100142044 0x100141f6c 0x18c9ecaa0 0x18caa1fb4 0x18caa1eb0 0x18caa134c 0x18caa0ff8 0x18caa0d18 0x18caa0c98 0x18c9e9648 0x18c341994 0x18c33c564 0x18c33c408 0x18c33bc08 0x18c33b98c 0x18cc76dbc 0x18cc77c68 0x18cc75dec 0x1904b162c 0x1881f2a28 0x1881f1b30 0x1881efd30 0x18811d0a4 0x18ca573c8 0x18ca523c0 0x1000747d8 0x198faea08)
libc++abi.dylib: terminating with uncaught exception of type NSException
I tried removing the custom exception handler that I have and disabling Crashlytics, still no success.
As soon as I remove arm64 from ARCHS and VALID_ARCHS the code works and the exception is caught as expected.
Any information will be appreciated!
Small update - our XCTests also started not to catch exceptions, up until now the behaviour only happened on physical 64bit phones.
After a long session of git-bisecting the culprit was the following linker flag
-no_compact_unwind
I Used BlocksKit v2.2.0 which still had that flag even though it stopped using libffi (latest version of BlocksKit removed that unneeded flag). As soon as I removed that linker flag 64bit #try...#catch blocks started to work again.
I still don't have complete understanding of why this behaviour happens but I'm going to dig a bit more and update this thread if I find anything interesting.
phew
On iOS and Objective-C Exceptions are only to be used for un-recoverable programming errors, not for program execution control.
In particular they do not handle catches accross stack frames inthe APIs.

Amazon SNS is crashed with SNSInvalidParameterException in iOS 8?

I have implemented AWS - Simple Notification Service and it was working fine, but after I upgraded my iOS 7 to iOS 8 application is crashed with :
*** Terminating app due to uncaught exception 'AmazonClientException', reason: ''
* First throw call stack:
(0x186f3e084 0x19751c0e4 0x100270224 0x10026f95c 0x1000dd7f0 0x187e0a60c 0x197d3fe80 0x197d3fddc 0x197d3cfb0)
libc++abi.dylib: terminating with uncaught exception of type SNSInvalidParameterException
After execution of below code snippet its crashing,
endPoint.platformApplicationArn = #"arn:aws:sns:eu-west-1:ID:app/APNS_SANDBOX/AppName_Dev";
[amazonClient createPlatformEndpoint:endPoint];
Thank you in advance.
Finally, I've got an solution, this is due to not using same user data for endPoint.customUserData. As Yosuke commented [AmazonLogger verboseLogging]; helped me a lot in tracking the bug.
So try to use same data (as in here #"Test") for one application.
endPoint.customUserData = #"Test";

Resources