I need to add deep linking feature to my app with Xamarin iOS.
My info.plist looks like this:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLSchemes</key>
<array>
<string>domine.somthing/index.html?UV</string>
</array>
<key>CFBundleURLTypes</key>
<string>com.domine.somthing/index.html?UV</string>
</dict>
I seems not working due to "/" char in the URL.
How am I supposed to write CFBundleURLTypes and CFBundleURLSchemes URL values in order to make it work?
Deep links can returns users directly to your application.
After adding URI support to your application like you did, just clicking on a URL consisting of a scheme name for your application will launch your app, but it seems you are filling CFBundleURLSchemes and CFBundleURLTypeswith with wrong values.
CFBundleURLName - Usually, this corresponds to the bundle ID of your
application. Please see Apple's Development doc for more informations.
CFBundleURLSchemes - Array of strings containing URL scheme names,
usually at least your application's name (without spaces). Pay
attentiont to ensure these values are unique to your application.
Look at this sample:
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleURLName</key>
<string>com.yourcompany.yourapp</string>
<key>CFBundleURLSchemes</key>
<array>
<string>appname</string>
</array>
</dict>
</array>
Now clicking on a URL consisting of appname:// on the device will launch your app.
If you want to send a user to a specific part of your application, you need to add arguments to this URL, making a deep link. Here is a sample with a path and query:
appname://custompath?customquery=customvalue
When a user clicks a URL containing your scheme (appname://), your app's delegate is called and specifically the method OpenUrl(UIApplication application, NSUrl url, string sourceApplication, NSObject annotation)where you can handle schemas an execute correct app routing based on schema arguments (if provided).
Related
I am trying to write an Electron application that lets users select photos from their photo library on macOS. My assumption is that the only way to access the photos without exporting them is by going into ~/Pictures/Photos Library.photoslibrary. However, when passing the file path of a photo to an <img> tag, I get net::ERR_ACCESS_DENIED error.
Is there a way to grant Electron application access to the user's photo library?
I've been writing code recently that accesses the PhotosLibrary. I did this by writing a native module that calls the PhotoKit API. If you go that direction there's going to be a steep learning curve as you'll likely be using Objective-C++ with the features and quirks of both C++ and Objective-C while trying to write something in JavaScript.
https://github.com/nodejs/node-addon-api
https://developer.apple.com/documentation/photokit?language=objc
With Apple's recent security features, you'll also need to somehow run your code inside of an app with the correct entitlements and values set in its Info.plist that will allow access to APIs.
In build/entitlements.mac.plist:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- https://github.com/electron/electron-notarize#prerequisites -->
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<!-- https://github.com/electron-userland/electron-builder/issues/3940 -->
<key>com.apple.security.cs.disable-library-validation</key>
<true/>
<!-- Allow app to access Photos Library using PhotoKit API -->
<key>com.apple.security.personal-information.photos-library</key>
<true/>
</dict>
</plist>
The following will be needed in your App's Info.plist:
<plist version="1.0">
<dict>
...
<key>NSPhotoLibraryUsageDescription</key>
<string>This app needs access to the photos library</string>
</dict>
</plist>
This can be done using electron-builder by adding the following value to the extendInfo extendInfo of your mac build settings in package.json.
{
...
"build": {
...
"mac": {
...
"extendInfo": {
...
"NSPhotoLibraryUsageDescription": "This app needs access to the photos library"
}
}
}
}
I hope this is gives you something to start with. Like I said above, this will come with a steep learning curve unless you're already familiar with JavaScript, native module development, Objective-C, C++ and Apple's APIs.
If you just need to read data from it for a one-off project, the photolibrary is really just a directory-like container around your photos, and an sqlite database for the metadata (faces, places and albums/folders). Right click-the photolibrary, show package contents, orig photos are under Masters/YYYY/MM/DD/IMG_XXXX.JPG format, and metadata is in database/photos.db, some tables you can query are RKMaster (filename/uuid of master files), RKAlbum, RKFace, RKMemory, RKPlace, RKFolder, RKVersion, RKKeyword, etc., get any free sqlite browser and you can figure out the rest.
You can also copy the .photolibrary file to Linux and scan its folder/sqlite file using pure node, you don't need any native modules to read it. Writing to it may try to fire some sqlite triggers that seem to belong to some macosx-proprietary extensions, so make backups first, try writes with extensions disabled, or just read and extract the images and metadata to some other format (raw jpeg/json files in a bucket somewhere) that are easy to collate and then (if you have to), reverse the process and write out to another photolibrary file once you get the relation between the tables and filesystem paths inside its container.
Newbie to modx and I am trying to build an image slider in Modx Revo. I am using Get resources but it does not output the template file. What am I doing wrong? This is my code:
[[getResources?
&resources=`[[*slide-img]]`
&parents=`-1`
&depth=`0`
&limit=`0`
&tpl=`slides`
&sortby=`FIELD(modResource.id,[[*slide-img]])`
&sortdir=`ASC`
&includeTVs=`1` &processTVs=`1` &tvPrefix=`tv.`
]]
From what I understand, you're trying to get all images from ressources in the resource tree. And show them in an image slider.
I guess you will have the javaScript for the image slider already present. So there is how to get the images.
You have a TV called slide-img, right? Good. Make sure it's output format is text.
If you refer to that image inside of a page that carries that TV, you call it like this
<img src="[[*slide-image]]" alt="some Image" />
If you call it in a chunk (what you will do when using getResources), you call the image like this:
<img src="[[+tv.slide-image]]" alt="some Image" />
See the difference? * is for the TV inside of the same page, + is the correct call for a placeholder. So if you're using getResources, it will put everything you query into the placeholders in your microtemplate (we call that chunk in MODX terms)
So your getResources call might look like this:
[[getResources?
&parents=`-1` (the place from where getResources will dig down the tree)
&depth=`0` (how deep will it dig?)
&limit=`0` (only the default 5? no! :) )
&tpl=`slides` (this is your chunk, right?)
&sortby=`FIELD(modResource.id,[[*slide-img]])` (you will sort by the file name and folder, is that right?)
&sortdir=`ASC`
&includeTVs=`1` &processTVs=`1` &tvPrefix=`tv.` (right, right, tv. is already the default value)
]]
getResources is a snippet used primarily to list documents, not images. A document (of type HTML, XML, CSS or JSON, to name a few) is created in the document tree in the manager and represents an example of a resource that you can get with getResources snippet.
Even if it is possible somehow to put an image as a document (which I doubt), it is not a common way anyway. Usually you want to attach an image to a document via template variable of corresponding type. For a slider particularly, you need many images, not one. So, you might need something specific like Gallery Extra to manage and output your images. Check out gallery section too. Note that basic version of MODX you have just installed isn't fully functional. We have to install extras to use MODX properly. Usually I install up to 30 extras.
Also your snippet call looks weird to me:
&resources=`[[*slide-img]]`
I don't know what the content of your template variable slide-img is but it should be a comma-separated list of resource ids like 2,4,6,34. Probably, in your case you have something different like image url and the snippet call silently crashes or just outputs nothing.
I have an iOS Project I'm working on using Xcode7 and Swift2. I have file association working great on it with PDF files. I did this in my Info.plist. I want to now associate it with images, particularly with JPG images. I have looked online and cannot find anything for this. Can someone please help?
For PDF I have:
Which looks like this in Source Code:
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>PDFIcon64.png</string>
<string>PDFIcon320.png</string>
</array>
<key>CFBundleTypeName</key>
<string>PDF</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.adobe.pdf</string>
</array>
</dict>
I tried copying the above and adjusting for JPG with no luck:
<dict>
<key>CFBundleTypeIconFiles</key>
<array>
<string>JPGIcon64.JPG</string>
<string>JPGIcon320.JPG</string>
</array>
<key>CFBundleTypeName</key>
<string>JPEG</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>com.xyz.JPG</string>
</array>
</dict>
I also tried this instead with no luck:
<dict>
<key>CFBundleTypeName</key>
<string>public.JPG</string>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>LSHandlerRank</key>
<string>Owner</string>
<key>LSItemContentTypes</key>
<array>
<string>public.JPG</string>
</array>
</dict>
When I'm viewing an image in my iOS Photo Library and click on the action button, it does not list my app in the area where the Message, Facebook, Twitter, etc. apps are located, like it does with PDF files from my Mail app. I've looked online in all kinds of forums with no luck for this.
For images that will be stores with the app you should consider using an Asset Catalog.
There is one asset catalog that defaults to every project and you can store images in there.
Once you add as asset to the catalog you can reference it in a string by the name you have it (without its extension).
For example
UIImage(named: "JPGIcon64")
Here is the link to the apple doc that talks about it here
According to the FreeMarker include statement docs, you can make header- and footer- aware templates like so:
<#include "/header.ftl">
<!-- Content of my this page -->
<#include "/footer.ftl">
But if my web app has hundreds of pages/views, this is a lot of redundant copy pasta. It would be great if there was like a "layout" concept in FreeMarker, where I could say "Hey, here is a layout:"
<#include "/header.ftl">
<#import_FTL_Somehow>
<#include "/footer.ftl">
And then create separate templates for each view/page (index.ftl, contactUs.ftl, etc.) and then tell FreeMarkers which FTL files "use" the layout. That way I wouldn't have to keep specifying header/footer includes in each and every template file.
Does FreeMarker support this kind of concept?
It doesn't, though if you only need a footer or header it can be solved with some TemplateLoader hack (where the TemplateLoader inserts the header and footer snippets, as if was there in the template file). But the usual solution in FreeMarker is calling the layout code explicitly from each templates, but not with two #include-s directly, but like:
<#my.page>
<!-- Content of my this page -->
</#my.page>
where my is an auto-import (see Configuration.addAutoImport).
Update: Another approach is that you have a layout.ftl like:
Heading stuff here...
<#include bodyTemplate>
Footer stuff here...
And then from Java you always call layout.ftl, but also pass in the body template name using the bodyTemplate variable:
dataModel.put("bodyTemplate", "/foo.ftl");
cfg.getTemplate("layout.ftl").process(dataModel, out);
In asp.net webpages framework what is the difference between using a content block versus a helper?
They both seem to be used to output HTML to multiple pages. They both can contain code and both can pass parameters.
Are there other differences? When should you use a helper versus a content block?
More info:
With Content Blocks we create a .cshtml (for example _MakeNote.cshtml) file to hold the content we want to insert into a page. Then we use:
#RenderPage("/Shared/_MakeNote.cshtml")
to insert the content into a page. We can pass parameters to the content block like this:
#RenderPage("/Shared/_MakeNote.cshtml", new { content = "hello from content block" })
It's somewhat like an include file, but I think does not share scope with the parent page.
With Helpers we create a .cshtml page in the App_Code folder (for example MyHelpers.cshtml) and place methods in that page which we want to call. The method looks something like this:
#helper MakeNote(string content) {
<div>#content</div>
}
The helper is called by using:
#MyHelpers.MakeNote("Hello from helper")
There isn't a lot of difference functionally. Helpers need to go into an App_Code folder - unless you download VWD or Visual C# Express and compile a binary - and the App_Code folder doesn't translate well to the MVC framework. Of course, that's only relevant if you want to upgrade to MVC at some point.
I would use a helper for generic functional snippets like your MakeNote. I would use a "content-block" (partial, really) for repeated site-specific sections of a page.