• Phil Bergner 8
  • NEWBIE
  • 0 Points
  • Member since 2015

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 0
    Questions
  • 3
    Replies
iOS app crashes while setting value of field in date format. Here is what happens we change a date field in our app, we create a salesforce request using salesforce REST API. The SFRestAPI class cannot convert that date filed into proper serialized JSON and causes app to crash throwing an error -  *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: 'Invalid type in JSON write (__NSDate)'

And here is the stack trace - 

*** First throw call stack:

(

    0   CoreFoundation                      0x043731e4 __exceptionPreprocess + 180

    1   libobjc.A.dylib                     0x03f648e5 objc_exception_throw + 44

    2   CoreFoundation                      0x04372fbb +[NSException raise:format:] + 139

    3   Foundation                          0x03a9b2e0 _writeJSONValue + 771

    4   Foundation                          0x03a9f7a2 ___writeJSONObject_block_invoke + 225

    5   CoreFoundation                      0x043fca7a __65-[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:]_block_invoke + 106

    6   CoreFoundation                      0x043fc97e -[__NSDictionaryM enumerateKeysAndObjectsWithOptions:usingBlock:] + 190

    7   CoreFoundation                      0x04361125 -[NSDictionary enumerateKeysAndObjectsUsingBlock:] + 53

    8   Foundation                          0x03a9f35f _writeJSONObject + 363

    9   Foundation                          0x03a9b1ec _writeJSONValue + 527

    10  Foundation                          0x03a9af9d -[_NSJSONWriter dataWithRootObject:options:error:] + 125

    11  Foundation                          0x03a9db57 +[NSJSONSerialization dataWithJSONObject:options:error:] + 369

    12  intouch.incall                      0x00b1bfc1 NRMA__ptrIntPtrParamHandler + 124

    13  intouch.incall                      0x00b1b504 NRMA__blk_ptrIntPtrParamHandler + 64

    14  intouch.incall                      0x004efbee +[SFJsonUtils JSONDataRepresentation:] + 90

    15  intouch.incall                      0x004efb34 +[SFJsonUtils JSONRepresentation:] + 43

    16  intouch.incall                      0x0084b233 __22-[SFRestRequest send:]_block_invoke + 43

    17  intouch.incall                      0x00851b01 -[MKNetworkOperation encodedPostDataString] + 141

    18  intouch.incall                      0x00857585 -[MKNetworkOperation bodyData] + 1872

    19  intouch.incall                      0x00858404 -[MKNetworkOperation start] + 1179

    20  Foundation                          0x03a2df44 __NSOQSchedule_f + 62

    21  libdispatch.dylib                   0x046b74d0 _dispatch_client_callout + 14

    22  libdispatch.dylib                   0x046a3fe0 _dispatch_async_redirect_invoke + 202

    23  libdispatch.dylib                   0x046b74d0 _dispatch_client_callout + 14

    24  libdispatch.dylib                   0x046a5eb7 _dispatch_root_queue_drain + 291

    25  libdispatch.dylib                   0x046a6127 _dispatch_worker_thread2 + 39

    26  libsystem_pthread.dylib             0x049e6dab _pthread_wqthread + 336

    27  libsystem_pthread.dylib             0x049eacce start_wqthread + 30

)

libc++abi.dylib: terminating with uncaught exception of type NSException
 
I am trying to add a custom Visualforce login page to my hybrid-remote app, which is connected to a SF community. What I have done is, created a Visualforce page, which collects the User's username and password and calls the following controller method:
 
public PageReference doLogin() {
	return Site.login(username, password, null);
}

When I try to login through a browser into the community, it works well. But, when I try to do it through the mobile app (created with SF Mobile SDK, i.e. forceios CLI), it gives me after clicking the login-button the following message:
"Can't connect to salesforce: The URL can't be shown".

What have I missed?
Thanks!
I have a problem with my hybrid-remote app build with the SF Mobile SDK. It is connected to a community (in XCode I have changed the SFDCOAuthLoginHost to the community domain). When the user logs in to the app, everything works. But when he tries to open the app after some time (my guess is, after the oauth token expires), the app just opens a blank screen. If he then closes the app, and re-opens it, it is working normally again.

In SF debug logs, I can see that the app is loading the "/apex/CommunitiesLogin" again and again. But it never ends up in the actual community.

Steps to reproduce the issue:
1) Create a community in your org, and a partner user for the community.
2) Create a conected app for the mobile app.
2) Create a new hybrid remote app, using the forceios CLI.
3) Open the hybrid app in XCode, and change the login URL to the communities' URL.
4) Run the app in a simulator (it shows the login page of the community)
5) Enter the credentials of the user, and login. -> App shows the community.
6) Go on your computer to the Salesforce org, and to Setup > Security Controls > Session Management.
7) Mark all items belonging to the community user, and click on "Remove" (this is to simulate the oauth token expiring)
8) In the simulator, close the app, and re-run.
9) The app shows only a blank screen.

Additional info:
- The connected app has all scopes available
- The issue is not occurring, when I try this with a full-license user login through the app (but, of course, he does not end up in the community)