Friday, June 16, 2017

ASP.NET: include javascript file in asp.net page

1. add the javascript file (for example, test.js) into the script folder

2. update BundleConfig.cs to create a new bundle for the js file
     bundles.Add(new ScriptBundle("~/bundles/test").Include(
                                  "~/Scripts/test.js"));


3. to add the js file for all views, update _layout.cshtml in <head> section
<head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>@ViewBag.Title - My ASP.NET Application</title>
    @Styles.Render("~/Content/css")
    @Scripts.Render("~/bundles/modernizr")
    @Scripts.Render("~/bundles/test")
</head>

or simple add the below line in any cshtml view
    @Scripts.Render("~/bundles/test")


Fiddler: Replay saved fiddler server response to repeat bug in Fiori client local testing

1. Setup Fiddler trace in customer site. Deleting and installing client app or reseting client app to delete all local cached response from device.

2. Start the client app with Fiddler trace enabled and repeat the issue, save the all session in fiddler trace after the testing

3. In local testing environment, open fiddler from local windows box, and open saved fiddle trace file

4. select and copy all session items and drag&drop to AutoResponder tab

5. url for certain requests may have "smphomebuster=" followed by a random timestamp string, in order to match those requests, delete the part after "smphomebuster=" and then delete the "EXACT:", and also select "Match only once" checkbox from the match rule as

6. select the checkbox of "Enable Rules" to start AutoResponder

7. from iOS device, connect to local Fiddler proxy and using the same fiori url to connect to start the app, and then repeat the same operation as customer does.

Note, not all session can be replayed properly, which needs more investigation


Thursday, June 15, 2017

SCP: testing app discovery service

1. From SCP trial account cockpit, select Services tab
2. Select Mobile Service -> App & Device Management tile
3. Select go to Admin console
4. click and open Applications item on list items on left
5. click Config App Discovery
6. add a new config by clicking "New Application Configuration" buttton

In order for fiori client to get configuration from application discovery service, the Config App Discovery setting in Mobile Secure must have ":1.0" at the end of the app id, the app id is set in appconfig.js or fiori url.

For example: com.sap.fiori.client.debug:1.0

Tuesday, June 13, 2017

Test ios app ipa file using ad hoc provision profile and test fligh

1) Using Ad hoc
When using ad hoc for ios testing, the testing device does not need to install the provision profile, the only thing required from testing device side is adding the device id to the apple developer account device list.

The same certificate used for Apple store distribution can also be used for Ad hoc, so there is no need to create a separate distribution certificate.

1. Add the explicit app id for the testing app in apple developer account
2. create ad hoc provision profile in apple developer account, which associates the appid, and all devices that will be used for ad hoc testing.
3. from xcode project, disable "Automatically manage signing" and set the provision profile to the created one.
4. archive the project
5. export the archive for ad hoc distribution, the ipa file will be created in the output folder.

Note sometimes xcode will generate a generic xcode archive instead of ios archive, most likely that is due to a library project included in the workspace has a header section in build phase, please refer to
https://developer.apple.com/library/content/technotes/tn2215/_index.html#//apple_ref/doc/uid/DTS40011221-CH1-PROJ
for details. To workaround, just remove the library project and direct link to the library's .a file.
In addition, if forgetting to set the app version number will also cause this issue.


2) Using testing flight
When using testing flight, you only need the email of the tester, the device used for testing must use the appid with same email from the tester.

1. build the project and then archive the project. Be sure the certificate and profile are all valid otherwise the app may not install by Test Flight
2. create an app from Apple ITune Connect
3. Upload the Archive from xcode to iTune
4. In ITune, select Test Flight to add the tester with email or add the tester into a group
5. In Test Flight, select Build iOS and make the build ready for testing.
6. select the build for testing and add the tester group or individual tester.

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.