Local notification phonegap ios - ios

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!

Related

iOS/Swift :: HERE Maps sporadicly crashing during init => [NSCFString hac_toVariant]

i'm currently facing an issue in two different projects using HEREMaps. Right after initializing via NMAApplicationContext.set(...) the app is crashing giving the following log:
2017-05-02 10:15:25.372 ANIO[3574:431630] -[NSCFString hac_toVariant]: unrecognized selector sent to instance 0x618000027560
2017-05-02 10:15:25.403 ANIO[3574:431630] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString hac_toVariant]: unrecognized selector sent to instance 0x618000027560'
*** First throw call stack:
(
0 CoreFoundation 0x000000010edccb0b __exceptionPreprocess + 171
1 libobjc.A.dylib 0x000000010e41c141 objc_exception_throw + 48
2 CoreFoundation 0x000000010ee3c134 -[NSObject(NSObject) doesNotRecognizeSelector:] + 132
3 CoreFoundation 0x000000010ed53840 ___forwarding_ + 1024
4 CoreFoundation 0x000000010ed533b8 _CF_forwarding_prep_0 + 120
5 ANIO 0x000000010d67819a _Z29PathToFileInWritableDirectoryP8NSString + 19706
6 ANIO 0x000000010d6bd98c _ZN6smart518segments_intersectExxxxxxxxPxS0_ + 55445
7 ANIO 0x000000010d6cdd8a _ZNSt3__110__list_impIN6smart517OrientedPointPairINS1_7geopt_tEEENS_9allocatorIS4_EEE5clearEv + 13288
8 ANIO 0x000000010d6cd1bb _ZNSt3__110__list_impIN6smart517OrientedPointPairINS1_7geopt_tEEENS_9allocatorIS4_EEE5clearEv + 10265
9 ANIO 0x000000010d6ee8a9 _ZNSt3__16vectorI11_GLKVector2NS_9allocatorIS1_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS1_RS3_EE + 97469
10 ANIO 0x000000010d6ee778 _ZNSt3__16vectorI11_GLKVector2NS_9allocatorIS1_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS1_RS3_EE + 97164
11 ANIO 0x000000010d6ee93e _ZNSt3__16vectorI11_GLKVector2NS_9allocatorIS1_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS1_RS3_EE + 97618
12 ANIO 0x000000010d6ef293 _ZNSt3__16vectorI11_GLKVector2NS_9allocatorIS1_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS1_RS3_EE + 100007
13 ANIO 0x000000010d6ecebc _ZNSt3__16vectorI11_GLKVector2NS_9allocatorIS1_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS1_RS3_EE + 90832
14 libdispatch.dylib 0x00000001122c44a6 _dispatch_call_block_and_release + 12
15 libdispatch.dylib 0x00000001122ed05c _dispatch_client_callout + 8
16 libdispatch.dylib 0x00000001122cb94f _dispatch_queue_serial_drain + 221
17 libdispatch.dylib 0x00000001122cc669 _dispatch_queue_invoke + 1084
18 libdispatch.dylib 0x00000001122ceec4 _dispatch_root_queue_drain + 634
19 libdispatch.dylib 0x00000001122cebef _dispatch_worker_thread3 + 123
20 libsystem_pthread.dylib 0x0000000112684746 _pthread_wqthread + 1299
21 libsystem_pthread.dylib 0x0000000112684221 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
anyone facing the same problems? any idea?
the only way to get rid of this error is de-/installing the app.
Kind regards,
Michael
OK, short update... the bug is easily reproducible.
1.)Download sample code from [link]https://developer.here.com/mobile-sdks/documentation/ios-starter/topics/quick-start.html
2.)Follow steps to include NMAKit-framework & NMAKit-bundle
3.)Build and run (Xcode Version 8.3.2 (8E2002)). Target simulator/hardware doesn't matter (tried iPhone 6/7/s simulator and hardware). Even using Obj-c or Swift sample makes no difference at all.
On first start everything's fine. Second start leads to crash.
2017-05-02 13:38:34.331 HelloMap[16821:1642096] -[NSCFString hac_toVariant]: unrecognized selector sent to instance 0x7f80266079a0
2017-05-02 13:38:34.342 HelloMap[16821:1642096] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[__NSCFString hac_toVariant]: unrecognized selector sent to instance 0x7f80266079a0'
*** First throw call stack:
(
0 CoreFoundation 0x000000010d9d9d85 __exceptionPreprocess + 165
1 libobjc.A.dylib 0x000000010d44ddeb objc_exception_throw + 48
2 CoreFoundation 0x000000010d9e2d3d -[NSObject(NSObject) doesNotRecognizeSelector:] + 205
3 CoreFoundation 0x000000010d928cfa ___forwarding_ + 970
4 CoreFoundation 0x000000010d9288a8 _CF_forwarding_prep_0 + 120
5 HelloMap 0x000000010cb6e9de _Z29PathToFileInWritableDirectoryP8NSString + 19706
6 HelloMap 0x000000010cbb41cc _ZN6smart518segments_intersectExxxxxxxxPxS0_ + 55445
7 HelloMap 0x000000010cbc4534 _ZNSt3__110__list_impIN6smart517OrientedPointPairINS1_7geopt_tEEENS_9allocatorIS4_EEE5clearEv + 13288
8 HelloMap 0x000000010cbc3965 _ZNSt3__110__list_impIN6smart517OrientedPointPairINS1_7geopt_tEEENS_9allocatorIS4_EEE5clearEv + 10265
9 HelloMap 0x000000010cbe5009 _ZNSt3__16vectorI11_GLKVector2NS_9allocatorIS1_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS1_RS3_EE + 97469
10 HelloMap 0x000000010cbe4ed8 _ZNSt3__16vectorI11_GLKVector2NS_9allocatorIS1_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS1_RS3_EE + 97164
11 HelloMap 0x000000010cbe509e _ZNSt3__16vectorI11_GLKVector2NS_9allocatorIS1_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS1_RS3_EE + 97618
12 HelloMap 0x000000010cbe59f3 _ZNSt3__16vectorI11_GLKVector2NS_9allocatorIS1_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS1_RS3_EE + 100007
13 HelloMap 0x000000010cbe361c _ZNSt3__16vectorI11_GLKVector2NS_9allocatorIS1_EEE26__swap_out_circular_bufferERNS_14__split_bufferIS1_RS3_EE + 90832
14 libdispatch.dylib 0x000000010fe90d9d _dispatch_call_block_and_release + 12
15 libdispatch.dylib 0x000000010feb13eb _dispatch_client_callout + 8
16 libdispatch.dylib 0x000000010fe9782c _dispatch_queue_drain + 2215
17 libdispatch.dylib 0x000000010fe96d4d _dispatch_queue_invoke + 601
18 libdispatch.dylib 0x000000010fe99996 _dispatch_root_queue_drain + 1420
19 libdispatch.dylib 0x000000010fe99405 _dispatch_worker_thread3 + 111
20 libsystem_pthread.dylib 0x00000001101ee746 _pthread_wqthread + 1299
21 libsystem_pthread.dylib 0x00000001101ee221 start_wqthread + 13
)
libc++abi.dylib: terminating with uncaught exception of type NSException
Thanks for reporting this, this is caused by us using Objective-C Categories in the HERE SDK and shipping it as a static library. One thing you can do is add the -ObjC linker flag to your build (OTHER_LDFLAGS) to get around this.
More info here: Categories In Static Libraries
This will be fixed in a future release.

Objective-C category for NSMutableDictionary not being respected in iOS10

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.

TUploadFile: crash while uploading video file which is picked from the library

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;

Can't log my t setAccessToken

I want to make a new object from string access_token.
I've made a Token:NSObject (.h + .m) and I'm trying to setAccessToken and show it in the NSLog. This is the code in my LoginViewController.m:
NSString *token = responseObject[#"access_token"];
Token *t = [[Token alloc]init];
[t setAccessToken:token];
NSLog(t);
And this is the error i get:
Create[29485:770358] -[Token _fastCStringContents:]: unrecognized
selector sent to instance 0x7f8e815d0780
Create[29485:770358] * Terminating app due to uncaught exception
'NSInvalidArgumentException', reason: '-[Token _fastCStringContents:]:
unrecognized selector sent to instance 0x7f8e815d0780'
* First throw call stack: ( 0 CoreFoundation 0x000000010149ff45 exceptionPreprocess + 165 1 libobjc.A.dylib
0x0000000100f19deb objc_exception_throw + 48 2 CoreFoundation
0x00000001014a856d -[NSObject(NSObject) doesNotRecognizeSelector:] +
205 3 CoreFoundation 0x00000001013f5eea
___forwarding_ + 970 4 CoreFoundation 0x00000001013f5a98 _CF_forwarding_prep_0 + 120 5
libsystem_trace.dylib 0x00000001036e8327
os_log_shim_with_CFString + 120 6 CoreFoundation
0x000000010148ef24 _CFLogvEx3 + 132 7 Foundation
0x0000000100b9489e _NSLogv + 117 8 Foundation
0x0000000100ae40f2 NSLog + 152 9 Create
0x00000001004d665b 21-[LoginVC UserLogin:]_block_invoke + 203 10
Create 0x00000001004d7f18
__64-[AFHTTPRequestOperation setCompletionBlockWithSuccess:failure:]_block_invoke49 + 40 11
libdispatch.dylib 0x00000001033fde5d
_dispatch_call_block_and_release + 12 12 libdispatch.dylib 0x000000010341e49b _dispatch_client_callout + 8 13 libdispatch.dylib
0x00000001034062af _dispatch_main_queue_callback_4CF + 1738 14
CoreFoundation 0x00000001014002e9
__CFRUNLOOP_IS_SERVICING_THE_MAIN_DISPATCH_QUEUE + 9 15 CoreFoundation 0x00000001013c18a9 __CFRunLoopRun
+ 2073 16 CoreFoundation 0x00000001013c0e08 CFRunLoopRunSpecific + 488 17 GraphicsServices
0x00000001056dcad2 GSEventRunModal + 161 18 UIKit
0x000000010184c30d UIApplicationMain + 171 19 Create
0x00000001004d6a2f main + 111 20 libdyld.dylib
0x000000010345292d start + 1 21 ???
0x0000000000000001 0x0 + 1 ) libc++abi.dylib: terminating with
uncaught exception of type NSException
Hope somebody can help me out!
NSLog(...) function assumes the first argument is an instance of NSString. If you want to use a different object, either use:
NSLog([t description]) or a format string NSLog(#"%#", t).

Local notification app crashes simulator

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.

Resources