I have cordova based iOS mobile app which need SSL certificate to be embedded with the mobile app & using the AFNetworking plugin to achieve the same.
When I run the build, I am getting the error NSCURLConnection finished with error - code -1003.
Attached the code screenshot.
https://i.stack.imgur.com/Elact.png
Please help.
From the screenshot I'd suggest changing that one line in the if statement as shown below.
if ( ... ) {
manager.securityPolicy.pinnedCertificates = [NSSet setWithObject:localCertificate];
}
Note the warning - you are passing data to an ivar that should get a set.
Then based on the -1003 error - double check the URL that you use. Make sure it is valid and accessible.
EDIT
Also, add the following two lines just before the if statement.
manager.requestSerializer = AFHTTPRequestSerializer.serializer;
manager.responseSerializer = AFHTTPResponseSerializer.serializer;
and see if it helps.
Related
Using the new iOS 9 feature - Universal links, from my understanding, is supposed top open my app whenever a specific domain is opened in browser (or other apps?). I have gone through the documentation and through this guide.
However, when the app opens I do not receive the parameter that is meant to help me open the correct page for the user to view....
I would share the code I'm using, but it's quite a big infrastructure and not really a couple of lines of code (server side JSON, plist rows and some IDs on the developer portal).
Anyone encountered it and could give me a hand here, please?
The Branch guide you linked to (full disclosure: I work with the Branch team) unfortunately doesn't cover a rather important step: what to do after your app opens. Which is exactly the issue you're encountering :). But the good news is you've already done the hard part with all the server and entitlement config.
What you need to complete the loop is a continueUserActivity handler in your AppDelegate.m file. This will pass you a webpageURL property containing the actual URL of the Universal Link that opened your app, which you can then parse and use for routing. It'll look something like this:
- (BOOL)application:(UIApplication *)application continueUserActivity:(NSUserActivity *)userActivity restorationHandler:(void (^)(NSArray *))restorationHandler {
if ([userActivity.activityType isEqualToString:NSUserActivityTypeBrowsingWeb]) {
NSString *myUrl = [userActivity.webpageURL absoluteString];
// parse URL string or access query params
}
return YES;
}
Also, when testing keep in mind that Universal Links unfortunately don't work everywhere yet:
P.S., gotta ask...since you found the Branch blog already, had you considered using the service to handle the link routing for you? It can definitely help simplify things!
I need to get the Versions of all the installed applications programmatically for non-jailbroken iOS devices.
Is it Possible to achieve this?
That's possible, please try the below code.
Class LSApplicationWorkspace_class = objc_getClass("LSApplicationWorkspace");
NSObject* workspace = [LSApplicationWorkspace_class performSelector:#selector(defaultWorkspace)];
for (LSApplicationProxy *apps in [workspace performSelector:#selector(allApplications)])
{
NSString *localizedName = apps.localizedName;
if([apps.applicationType isEqualToString:#"User"])
{
NSLog(#"\nlocalizedName: %#",localizedName);
NSLog(#"minimumSystemVersion: %#",apps.minimumSystemVersion);
NSLog(#"fileSharingEnabled: %d",apps.fileSharingEnabled);
NSLog(#"sdkVersion: %#",apps.sdkVersion);
NSLog(#"teamID: %#",apps.teamID);
}
}
For this you need to place 4 classes in your app:
LSApplicationWorkspace, LSResourceProxy, LSBundleProxy, LSApplicationProxy.
In iOS8 and before, we can use canOpenUrl to get installed applications which registered schemes. In iOS9, you must add a "white list" into your info.plist file. Only the application in the "white list" can be checked. And the limit count of the "white list" is 50. So you'd better jailbreak your device.
See more information: How to check particular app is already installed on iphone device or not?
Another one: http://useyourloaf.com/blog/querying-url-schemes-with-canopenurl.html
I am trying a simple sample app on XPCServices, in which I am following below steps:
Step 1: Created a sample project and added target - XPCServices with name - HelperProcess to it. When the target is created XCode automatically generates below files:
HelperProcessProtocol.h
HelperProcess.h
HelperProcess.m
main.m
Step 2: In main.m added a log statement within implementation of ServiceDelegate:
- (BOOL)listener:(NSXPCListener *)listener shouldAcceptNewConnection:(NSXPCConnection *)newConnection {
// This method is where the NSXPCListener configures, accepts, and resumes a new incoming NSXPCConnection.
NSLog(#"Log which is never displayed :(");
// Configure the connection.
// First, set the interface that the exported object implements.
newConnection.exportedInterface = [NSXPCInterface interfaceWithProtocol:#protocol(HelperProcessProtocol)];
// Next, set the object that the connection exports. All messages sent on the connection to this service will be sent to the exported object to handle. The connection retains the exported object.
HelperProcess *exportedObject = [HelperProcess new];
newConnection.exportedObject = exportedObject;
// Resuming the connection allows the system to deliver more incoming messages.
[newConnection resume];
// Returning YES from this method tells the system that you have accepted this connection. If you want to reject the connection for some reason, call -invalidate on the connection and return NO.
return YES;
}
Step 3: In AppDelegate added below code in applicationDidFinishLaunching:
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
// Insert code here to initialize your application
_connectionToService = [[NSXPCConnection alloc] initWithServiceName:#"HelperProcess"];
_connectionToService.remoteObjectInterface = [NSXPCInterface interfaceWithProtocol:#protocol(HelperProcessProtocol)];
[_connectionToService resume];
}
Problem is -
When I launch the app, neither the log added in
listener:shouldAcceptNewConnection: is displayed nor the helper
process appears in Activity Monitor :(
Here is the code: XPCShootOut
Note: I am trying this on XCode 6.0
Is there any additional setup which I need to do to make it working? Please suggest.
-- Update --
I tried to refer this sample from apple: AppSandboxLoginItemXPCDemo
When I tried to run it on XCode 6, it displayed error message - 'No signing identity found'. Since I don't have registered mac developer account, in build settings for - iDecide and iDecideHelper I changed 'Code Signing Identity' as 'Don't Code Sign'.
I got a warning for each of the targets:
Code Sign warning: CODE_SIGN_ENTITLEMENTS specified without specifying CODE_SIGN_IDENTITY. It is not possible to add entitlements to a binary without signing it.
This time when I compiled the build, it worked as expected.
Now I tried to follow the steps specified in its ReadMe.txt file, specifically I performed these steps in my sample app:
Step 1: Updated - Main App Target -> Capabilities Tab
Turned on 'App Sandbox'
Turned on 'App Groups'
Added an app group - 'XYZ'
Step 2: Updated - Helper Target -> Capabilities Tab
Turned on 'App Sandbox'
Enabled 'Outgoing Connections (Client)'
Turned on 'App Groups'
Added an app group - 'XYZ'
Step 3: Updated - Helper Target -> General Tab -> Bundle Identifier, added 'XYZ' prefix to it.
On running the app in console it displayed these messages:
10/12/14 6:27:42.159 PM xpcd[554]: (null): Code identity[pid: 11875::Devarshi-Kulshreshtha.XPCShootOut (/Users/devarshi/Library/Developer/Xcode/DerivedData/XPCShootOut-aaedwraccpinnndivoaqkujcmhmj/Build/Products/Debug/XPCShootOut.app)] is not in ACL for container: ~/Library/Containers/Devarshi-Kulshreshtha.XPCShootOut/Data -- allowing access.
10/12/14 6:27:43.712 PM appleeventsd[63]: <rdar://problem/11489077> A sandboxed application with pid 11875, "XPCShootOut" checked in with appleeventsd, but its code signature could not be validated ( either because it was corrupt, or could not be read by appleeventsd ) and so it cannot receive AppleEvents targeted by name, bundle id, or signature. Error=ERROR: #100013 { "NSDescription"="SecCodeCopySigningInformation() returned 100013, -." } (handleMessage()/appleEventsD.cp #2072) client-reqs-q
Neither app performed its intended function nor it displayed the log message added in listener:shouldAcceptNewConnection: delegate.
I am clueless. Kindly suggest if I am missing any thing? Is it possible to get XPC service sample app working without a registered mac developer account?
I don't think you can launch XPC services without having them signed.
Even for testing and debugging the code sign build infrastructure needs to be setup.
I think the Mac developer certificate is free you don't need a paid account for that.
Given an application's pid, is there any way, programatically, of detecting if that application is running in an OSX sandbox environment?
Ideally, I'd like to know if there's an API call somewhere, preferably in C, rather than objective-C (for a daemon, so not using Cocoa), but if not, is there any other way of checking?
#Linuxios was right partly right about there being a CoreFoundation call. In fact, there are a few that when combined, can be used to solve this and it's based on the call to SecStaticCodeCheckValidityWithErrors
For anyone that may want, or need to programmatically test for an app being sandboxed can follow this blog.
Also, the full code to the article has been added to Github here.
First you must get the path of the application from the pid, and then you can use the command codesign --display --entitlements - app_path to view all the entitlements. If the app has the entitlements com.apple.security.app-sandbox set to true then it is sandboxed.
You can take a look here.
For detecting the sandbox in Flex/AIR/AS3 you can use the following kludge. The same approach should also work in objc. The only condition under which this would not work would be if the Documents folder were entirely empty. Or you could use any other folder that is off-limits to the sandbox.
var file:File = File.userDirectory;
var a:Array = file.nativePath.split("/");
var userName:String = a[2];
var docFolder:File = new File("/Users/" + userName + "/Documents/");
var dirList:Array = docFolder.getDirectoryListing();
if (dirList.length>0) {
docDirectoryDisplay.text = "App is NOT sandboxed.";
} else {
docDirectoryDisplay.text = "App is sandboxed.";
}
I am trying to use WL.TabBar api and create tabs in the server generated pages but looks like items are not rendered as tabs. But rendered one below the other with dots for each items (like indicated/shown below).
*Item1
*Item2
*Item3
*Item4
Any idea what could be the problem ?. Thanks
Cool, Here are the environment details:
(1) Worklight version 506. Running on Android simulator
(2) Sample code used:
WL.TabBar.setParentDivId("tabpane");
WL.TabBar.init();
WL.TabBar.addItem("item1", function()
{ openNativePage(); },"Item1",{ image: "css/images/Tab.jpg",
imageSelected : "css/images/Tab.jpg"
? });
WL.TabBar.setVisible(true);
(3) I don't see any error messages as such. But I see the below warning in LogCat:
05-16 12:37:42.796: I/Web Console(289): Falling back on PROMPT mode since _cordovaNative is missing. at hostname/wps/contenthandler/!ut/p/digest!SlQs_clcwL2z1b8kIsNvEg/mashup/ra:collection?themeID=ZJ_CGAH47L00OEP00IDBHRNLP0830&locale=en&mime-type=text%2Fplain&entry=wl_client__0.0%3Aconfig_js&entry=wl_init__0.0%3Aconfig_js&entry=wp_theme_high_contrast__0.0%3Aconfig_js&entry=wp_theme_edit__0.0%3Aconfig_js&entry=wp_theme_menus__0.0%3Aconfig_js&entry=wp_theme_skin_region__0.0%3Aconfig_js&entry=wp_one_ui_30__0.0%3Aconfig_js&entry=wp_status_bar__0.0%3Aconfig_js:1044
hmm, I think found the answer. The problem was the CSS files (wlclient.css + wlgap.android.css) were missing at backed the Server (where the custom application exist). I had copied only the native JavaScript files from wlclient and commons folder. Thanks.