Saturday, May 13, 2017

ios 10.3 test tip

1. If the app work in real device, but crash on ios simulator, then enable keychain share in target capability entitlement setting.

2. If the server self signed certificate is imported as email attachment, it is not accepted by iOS network connection by default. In order to trust the certificate for https connection, go to device settings->general->about->certificate trust Settings page, and be sure the installed server cert is trusted in there. 

SCP: Steps to use SAP mobile secure trial account for ios device management test

1. login your SAP Cloud Platform Cockpit using your trial account, select service App & Device Management.
2. Click Go to Admin console to open mobile secure admin portal
3. Select User->Manage Users, and edit the only user available
4. select action to edit, and change the user type from unmanaged to managed
5. Select Account->Device Setup, and then clickin iOS
6. In Apple MDM Certificate section, follow the step to download the csr request from the link, then upload to Apple site to get the certificate. Then upload it in step 3. A message box will indicate the operation succeeded.
7. Open Client App tab, to sign the ios afaria app.
  7.1 First create an explicit appid in your Apple developer portal web site, for example, com.sap.mobilesecure.me
  7.2 Create a development provision profile with the App ID and your development sign certificate, including all devices registered in apple dev portal
  7.3 Export your development signing p12 file from keychain
  7.4 Click Sign ios client button to Sign mobile Afaria client with above information
8. Create push certificate for sending push notification to Mobile Afaria
  8.1 From apple dev portal, create a push certificate for production with the same app id set in step 7.1
  8.2 download the push cert and import into keychain.
  8.3 export p12 file from keychain and click Install button to install it into mobile secure
9. from SAP Cloud Platform Cockpit using your trial account, select service App & Device Management, ang then Goto Mobile place
10. copy the url and open it from your ios mobile safari, the url should look like https://trial-i826633trial.sapmobileplace.com
11. follow the instruction to enroll the device
12. once it is done, it should start downloading Afaria app you just signed
13. You can also verify the push function by locking and unlocking the device from mobile secure device management.


Sunday, May 7, 2017

Which viewcontroller gets dismissed when calling iOS dismissViewController method

Apple document has the below information regarding the below method:
dismissViewControllerAnimated:completion: 
Dismisses the view controller that was presented modally by the view controller.

Discussion
The presenting view controller is responsible for dismissing the view controller it presented. If you call this method on the presented view controller itself, UIKit asks the presenting view controller to handle the dismissal.

This document is quite confusing as there are three view controllers are involved in the operation.
self  (this is the current viewController receiving the method call)
self.presentedViewController
self.presentingViewController

So in different cases, which view controller is really got dismissed?

A quick testing shows the actual logic is implemented as below:
When dismissViewControllerAnimated method is called on a ViewController object, it first checks whether the current viewControlller's presentedViewController contains a valid object, if so, then just dismisses the presentedViewController and returns.

If the current ViewController's presentedViewController is nil, then it will dismiss the current viewController. Internally by forwarding the message to its presentingViewController as Apple document mentions. 

So basically, the method will dismiss self.presentedViewController. If the self.presentedViewController is nil, then it will dismiss the current viewController which receives the method call.