I'm using the local notification plugin (https://github.com/katzer/cordova-plugin-local-notifications/) with ng-cordova for an ionic poject:
This is my controller:
.controller('DashCtrl', function($scope, $state, $cordovaLocalNotification) {
$scope.addNotification = function() {
$cordovaLocalNotification.add({
id: 'some_notification_id'
// parameter documentation:
// https://github.com/katzer/cordova-plugin-local-notifications#further-informations-1
}).then(function() {
console.log('callback for adding background notification');
});
};
$scope.checkIfIsTriggered = function() {
$cordovaLocalNotification.isTriggered('some_notification_id').then(
function(isTriggered) {
alert('isTriggered');
});
};
})
I have a button on the default view which is loaded when the app starts with a ng-click, like so:
<button ng-click="addNotification();" class="button button-stable">button-stable</button>
But when I run the app in the emulator and tap the button, the app crashes with the followiing error message:
: *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '- [__NSCFString stringValue]: unrecognized selector sent to instance 0x7a840850'
*** First throw call stack:
(
0 CoreFoundation 0x002cc1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x023848e5 objc_exception_throw + 44
2 CoreFoundation 0x00369243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x002bc50b forwarding + 1019
4 CoreFoundation 0x002bc0ee CFforwarding_prep_0 + 14
5 new 0x0011f917 -[APPLocalNotification notificationWithId:] + 503
6 new 0x0011f6a6 -[APPLocalNotification isNotificationScheduledWithId:] + 86
7 new 0x0011bccf __28-[APPLocalNotification add:]blockinvoke + 207
8 libdispatch.dylib 0x0293d7b8 dispatchcall_block_and_release + 15
9 libdispatch.dylib 0x029524d0 dispatchclient_callout + 14
10 libdispatch.dylib 0x02940eb7 dispatchroot_queue_drain + 291
11 libdispatch.dylib 0x02941127 dispatchworker_thread2 + 39
12 libsystem_pthread.dylib 0x02c89dab pthreadwqthread + 336
13 libsystem_pthread.dylib 0x02c8dcce start_wqthread + 30
)
Oct 19 11:54:21 xxxx-MacBook-Air.local backboardd[27466] : Application 'UIKitApplication:com.ionicframework.new903016[0xde04]' exited abnormally with signal 6: Abort trap: 6"
Has anyone got it to work following the ng-cordova docs, or is there another approach I should be trying.
Thank's!
If you're still having this issue, I ran into this today as well.
Go into the plugin code, APPLocalNotifications.m in Xcode and change this line, towards the bottom:
NSString* notId = [[notification.userInfo objectForKey:#"id"]
stringValue];
and replace it with this:
NSString* notId = [notification.userInfo objectForKey:#"id"];
This worked for me today.
Related
I have an app written in Objective-C with a category for NSMutableDictionary. In iOS9, the app works fine. However when run in iOS10, the app crashes due to an 'unrecognized selector sent to instance'. I've isolated the problem to the NSMutableDictionary category not being respected in iOS10.
The category for NSMutableDictionary includes the following method:
- (id)getObjectForStringKeyPath:(NSString *)keysPath {
NSArray *dividedString = [keysPath componentsSeparatedByString:#"/"];
return [self getObjectForKeyPath:dividedString];
}
The line which it is crashing at is (response is type 'id'):
NSArray *textArray = [response getObjectForStringKeyPath:"someText/text"];
I've checked the response from the server and the response is valid. Also as I mentioned the crash does not happen on iOS9. It only happens on iOS10.
Does anyone know how to solve this, or any approaches to take for this problem?
Crash log
-[__NSSingleEntryDictionaryI getObjectForStringKeyPath:]: unrecognized selector sent to instance 0x608000a3f3e0
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSSingleEntryDictionaryI getObjectForStringKeyPath:]: unrecognized selector sent to instance 0x608000a3f3e0'
*** First throw call stack:
(
0 CoreFoundation 0x000000011036034b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010fdc121e objc_exception_throw + 48
2 CoreFoundation 0x00000001103cff34 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x00000001102e5c15 ___forwarding___ + 1013
4 CoreFoundation 0x00000001102e5798 _CF_forwarding_prep_0 + 120
5 XYZApp 0x000000010c919b7e __64-[XYZController configureConditionsTextFromHTML:]_block_invoke + 126
6 XYZApp 0x000000010c8e973f __41-[XYZDataProvider getTermsAndConditions:]_block_invoke + 159
7 XYZApp 0x000000010c8fd5ae -[XYZManager handleSuccessfulResponse:andResponseBlock:] + 110
8 XYZApp 0x000000010c8fbede __50-[XYZManager GET:withParameters:andResponseBlock:]_block_invoke + 126
9 libdispatch.dylib 0x0000000110872980 _dispatch_call_block_and_release + 12
10 libdispatch.dylib 0x000000011089c0cd _dispatch_client_callout + 8
11 libdispatch.dylib 0x000000011087ca1d _dispatch_main_queue_callback_4CF + 733
12 CoreFoundation 0x00000001103244f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
13 CoreFoundation 0x00000001102e9f8d __CFRunLoopRun + 2205
14 CoreFoundation 0x00000001102e9494 CFRunLoopRunSpecific + 420
15 GraphicsServices 0x00000001131c9a6f GSEventRunModal + 161
16 UIKit 0x000000010e573f34 UIApplicationMain + 159
17 XYZApp 0x000000010c92698f main + 111
18 libdyld.dylib 0x00000001108e868d start + 1
19 ??? 0x0000000000000001 0x0 + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
The error says that the object type is __NSSingleEntryDictionaryI, not the NSMutableDictionary that you expect.
Make a mutable copy of the dictionary that the server gives you and assign that to response.
For some undocumented reason, iOS10 believes the object type is an NSDictionary, so I created a category for NSDictionary with the getObjectForStringKeyPath method. This was the cleanest and most efficient solution for my problem.
My application crashes when user try to upload a video to Quickblox server, after picking the video from the library. The same method works flawlessly if we try to upload an image or video captured from the camera. Thoughts?
Environment details
"QB-SDK" = "iOS 2.2.2";
"QuickBlox-REST-API-Version" = "0.1.1";
Did this work before?
Yes
Expected behavior
Video should upload successfully, or an error should be returned.
Actual behavior
Application crash.
Logs
json: {"blob":{"name":"video","content_type":"video\/quicktime"}}
Request URL:https://api.quickblox.com/blobs.json
Request method: POST
Request parameters:{
blob = {
"content_type" = "video/quicktime";
name = video;
};
}
*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFType _enableCropOverlayIfNecessary]: unrecognized selector sent to instance 0x7fcd54526650'
*** First throw call stack:
(
0 CoreFoundation 0x0000000105745d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x0000000108f3bdeb objc_exception_throw + 48
2 CoreFoundation 0x000000010574ed3d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x0000000105694cfa ___forwarding___ + 970
4 CoreFoundation 0x00000001056948a8 _CF_forwarding_prep_0 + 120
5 PhotoLibrary 0x000000011f852a50 -[PLVideoRemaker _exportCompletedWithSuccess:] + 135
6 AssetsLibraryServices 0x0000000115768709 __pl_dispatch_async_block_invoke + 25
7 libdispatch.dylib 0x000000010a837d9d _dispatch_call_block_and_release + 12
8 libdispatch.dylib 0x000000010a8583eb _dispatch_client_callout + 8
9 libdispatch.dylib 0x000000010a8401ef _dispatch_main_queue_callback_4CF + 1738
10 CoreFoundation 0x000000010569f0f9 __CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE__ + 9
11 CoreFoundation 0x0000000105660b99 __CFRunLoopRun + 2073
12 CoreFoundation 0x00000001056600f8 CFRunLoopRunSpecific + 488
13 GraphicsServices 0x000000010afaead2 GSEventRunModal + 161
14 UIKit 0x000000010754bf09 UIApplicationMain + 171
15 MyApp 0x00000001043cc85f main + 111
16 libdyld.dylib 0x000000010a88d92d start + 1
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Steps to reproduce the behavior
Call the upload method for video that is picked from the library:
+ (QBRequest *)TUploadFile:(NSData*)data
fileName:(NSString*)fileName
contentType:(NSString*)contentType
isPublic:(BOOL)isPublic
successBlock:(void(^)(QBResponse *response, QBCBlob* blob))successBlock
statusBlock:(QBRequestStatusUpdateBlock)statusBlock
errorBlock:(void(^)(QBResponse *response))errorBlock;
I'm using Local Notification plugin for a phonegap iOS app. When I try to add a new Notification, the app throw a NSInvalidArgumentException.
Here is the code when i add a notification:
var now = new Date().getTime(),
_60_seconds_from_now = new Date(now + 60*1000);
window.plugin.notification.local.add({
id: 1,
title: 'Reminder',
message: 'Dont forget to buy some flowers.',
repeat: false,
date: _60_seconds_from_now
});
And here is the output
Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFNumber isEqualToString:]: unrecognized selector sent to instance 0xa26c650'
*** First throw call stack:
(
0 CoreFoundation 0x000dd1e4 __exceptionPreprocess + 180
1 libobjc.A.dylib 0x021948e5 objc_exception_throw + 44
2 CoreFoundation 0x0017a243 -[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x000cd50b ___forwarding___ + 1019
4 CoreFoundation 0x000cd0ee _CF_forwarding_prep_0 + 14
5 OPS 0x000276e9 -[APPLocalNotification notificationWithId:] + 521
6 OPS 0x00027246 -[APPLocalNotification isNotificationScheduledWithId:] + 86
7 OPS 0x00023458 __28-[APPLocalNotification add:]_block_invoke + 200
8 libdispatch.dylib 0x027527b8 _dispatch_call_block_and_release + 15
9 libdispatch.dylib 0x027674d0 _dispatch_client_callout + 14
10 libdispatch.dylib 0x02755eb7 _dispatch_root_queue_drain + 291
11 libdispatch.dylib 0x02756127 _dispatch_worker_thread2 + 39
12 libsystem_pthread.dylib 0x02a96dab _pthread_wqthread + 336
13 libsystem_pthread.dylib 0x02a9acce start_wqthread + 30
)
libc++abi.dylib: terminating with uncaught exception of type NSException
any idea? Thank you.
Your id param is not string, but the plugin seem to require a string value for id.
I find the solution. If you are using iOS 7.1, you must replace this line
NSString* notId =[notification.userInfo objectForKey:#"id"];
for this
NSString* notId =[NSString stringWithFormat:#"%#", [notification.userInfo objectForKey:#"id"]];
in the method notificationWithId.
Thanks for the help!
I'm having a pretty consistent issue here, and have literally searched everywhere to no avail. I've been having a ton of problems with CocoaLibSpotify, and this error is just more hours being wasted of my employer, but anyways.
Whenever I attempt to login or do an SPSearch I get an unrecognized selector and the application crashes. Here's the code below. Thanks for your patience!
SPDispatchAsync(^{
NSError *error = nil;
//[SPSession class];
[SPSession initializeSharedSessionWithApplicationKey:[NSData dataWithBytes:&g_appkey length:g_appkey_size]
userAgent:#"com.mattie.montgomery.listenin"
loadingPolicy:SPAsyncLoadingManual
error:&error];
if (error != nil) {
NSLog(#"CocoaLibSpotify init failed: %#", error);
abort();
}
[[SPSession sharedSession] setDelegate:self];
[[SPSession sharedSession] attemptLoginWithUserName:#"USERNAME" password:#"PASSWORD"];
// playbackManager = [[SPPlaybackManager alloc] initWithPlaybackSession:[SPSession sharedSession]];
//[search addObserver:self forKeyPath:#"searchInProgress" options:NSKeyValueObservingOptionNew context:NULL];
// search = [SPSearch searchWithSearchQuery:#"What is love" inSession:[SPSession sharedSession]];
});
Here's the exception:
2014-01-13 13:24:48.890 ListenIn[47201:4303] +[NSError spotifyErrorWithCode:]: unrecognized selector sent to class 0x2cd8298
2014-01-13 13:24:48.979 ListenIn[47201:4303] * Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '+[NSError spotifyErrorWithCode:]: unrecognized selector sent to class 0x2cd8298'
* First throw call stack:
(
0 CoreFoundation 0x030835e4 exceptionPreprocess + 180
1 libobjc.A.dylib 0x02e068b6 objc_exception_throw + 44
2 CoreFoundation 0x031207a3 +[NSObject(NSObject) doesNotRecognizeSelector:] + 275
3 CoreFoundation 0x0307390b __forwarding + 1019
4 CoreFoundation 0x030734ee _CF_forwarding_prep_0 + 14
5 ListenIn 0x00039a6b logged_in + 139
6 ListenIn 0x0018c1de sp_session_set_private_session + 538
7 ListenIn 0x000f0cf7 -[SPClientUpsellViewController .cxx_destruct] + 639639
8 ListenIn 0x0009c277 -[SPClientUpsellViewController .cxx_destruct] + 292887
9 ListenIn 0x0018af5f sp_session_process_events + 80
10 ListenIn 0x0003854c -[SPSession prodSessionForcefully] + 332
11 ListenIn 0x0003cf2c notify_main_thread_block_invoke + 44
12 ListenIn 0x0002b63d __54+[SPSession dispatchToLibSpotifyThread:waitUntilDone:]_block_invoke + 93
13 CoreFoundation 0x030421c0 __CFRUNLOOP_IS_CALLING_OUT_TO_A_BLOCK + 16
14 CoreFoundation 0x0300b3f9 CFRunLoopDoBlocks + 361
15 CoreFoundation 0x03029843 __CFRunLoopRun + 2355
16 CoreFoundation 0x03028ac3 CFRunLoopRunSpecific + 467
17 CoreFoundation 0x03033e61 CFRunLoopRun + 129
18 ListenIn 0x0002b905 +[SPSession runBackgroundRunloop:] + 437
19 Foundation 0x02a5e597 -[NSThread main] + 76
20 Foundation 0x02a5e4f6 _NSThread_main + 1275
21 libsystem_pthread.dylib 0x05dc15fb _pthread_body + 144
22 libsystem_pthread.dylib 0x05dc1485 _pthread_struct_init + 0
23 libsystem_pthread.dylib 0x05dc6cf2 thread_start + 34
)
libc++abi.dylib: terminating with uncaught exception of type NSException
First, don't put account credentials like your username and password on the public internet.
As for your problem, pasting in a big block of code isn't very helpful - which line actually generates the error?
Your commented out code at the bottom is in the wrong order - you can't add an observer to something until after you've created it.
Finally, please re-read the readme, specifically the part about threading. You only need to use SPDispatchAsync in very specific circumstances, and you should never be using it in normal usage like this.
The answer was to add the -ObjC linker flag and add the Facebook API to the project. Thanks to iKenndac for the suggestion.
I have a strange problem with TestFlight SDK. On iPhone5 I get this exception, app crashed.
Here is backtrace:
Reason: -[__NSArrayM length]: unrecognized selector sent to instance 0x20c76d80
UserInfo: (null)
Backtrace: (0x3abbc2a3 0x34aab97f 0x3abbfe07 0x3abbe531 0x3ab15f68 0x3591b0c1 0x996eb 0xb2b83 0x97b21 0x973ed 0x75913 0x83657 0x839e7 0x38eaf11f 0x38eb3961 0x38eb3ac1 0x35c18a11 0x35c188a4)
Stack symbols: (
0 CoreFoundation 0x3abbc2bb <redacted> + 186
1 libobjc.A.dylib 0x34aab97f objc_exception_throw + 30
2 CoreFoundation 0x3abbfe07 <redacted> + 170
3 CoreFoundation 0x3abbe531 <redacted> + 392
4 CoreFoundation 0x3ab15f68 _CF_forwarding_prep_0 + 24
5 Foundation 0x3591b0c1 <redacted> + 160
6 FlyerApp 0x000996eb +[TFAirTrafficController logPath] + 102
7 FlyerApp 0x000b2b83 -[TFMessagePackLogOperation writeLogData] + 50
8 FlyerApp 0x00097b21 TFLogv + 92
9 FlyerApp 0x000973ed TFLog + 60
10 FlyerApp 0x00075913 -[KFRemoteLoadManager changesRequestFromDate:forDelegate:] + 834
11 FlyerApp 0x00083657 -[KFSyncManager _startSync] + 574
12 FlyerApp 0x000839e7 __31-[KFSyncManager tryToStartSync]_block_invoke_0132 + 54
13 libdispatch.dylib 0x38eaf11f <redacted> + 10
14 libdispatch.dylib 0x38eb3961 <redacted> + 252
15 libdispatch.dylib 0x38eb3ac1 <redacted> + 84
16 libsystem_c.dylib 0x35c18a11 <redacted> + 360
17 libsystem_c.dylib 0x35c188a4 start_wqthread + 8
)
I suggest that code which cause this exception is next:
NSString *urlString = [NSString stringWithFormat:BASE_URL, [[KFLocalDataManager sharedManager] serverName]];
urlString = [[urlString stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding] stringByAppendingString:methodName];
NSURL *url = [NSURL URLWithString:urlString];
TTLog(#"Request URL - '%#'", url);
Where TTLog is
#define TTLog(__FORMAT__, ...) TFLog((#"%s [Line %d] " __FORMAT__), __PRETTY_FUNCTION__, __LINE__, ##__VA_ARGS__);
url string is url to server like this:
https://xxxxxx.xxxxxxx.com/xxxxx_xxxx/xxxx
This error occurs not every time but always in this place. I have several crash but I cannot see some similar environment for all same crash issues.
Also this code running in not main app thread and sometimes in iOS background.
Maybe TFLog have some restrictions for incoming parameters or somebody receive same or similar exception with TestFlight?
I work at TestFlight on the SDK. #Nevir is correct. Unfortunately, TFLog is not thread safe. This issue has been recently brought to our attention. I'm working on an update that will fix this issue and hope to have a beta out soon. I'll keep you updated.
There is a new beta that fixes this issue: 1.3.0-beta. Get it here: https://testflightapp.com/sdk/download/ (look for "Feeling Adventurous?")