incubator-callback-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
Subject ios commit: Fixes CB-851 - guide for using url schemes in ios
Date Fri, 01 Jun 2012 23:53:39 GMT
Updated Branches:
  refs/heads/master 982d0bb3f -> 4d71555c4

Fixes CB-851 - guide for using url schemes in ios


Branch: refs/heads/master
Commit: 4d71555c4474ce068267d8a63b0cdd797417a9fe
Parents: 982d0bb
Author: Shazron Abdullah <>
Authored: Fri Jun 1 16:53:28 2012 -0700
Committer: Shazron Abdullah <>
Committed: Fri Jun 1 16:53:28 2012 -0700

 Makefile                                     |    5 ++
 guides/Cordova Custom URL Scheme |   44 +++++++++++++++++++++
 2 files changed, 49 insertions(+), 0 deletions(-)
diff --git a/Makefile b/Makefile
index 214f430..a60c781 100644
--- a/Makefile
+++ b/Makefile
@@ -212,6 +212,7 @@ installer: check-utils clean check-wkhtmltopdf md-to-html cordova-lib
 	@$(WKHTMLTOPDF) --footer-center "Cordova ${CDV_VER} Plugin Upgrade Guide" CordovaInstaller/docs/plugin_upgrade.html
'dist/files/Guides/Cordova Plugin Upgrade Guide.pdf' > /dev/null 2>> $(PKG_ERROR_LOG)
 	@$(WKHTMLTOPDF) --footer-center "Cordova ${CDV_VER} Settings File" CordovaInstaller/docs/settings_file.html
'dist/files/Guides/Cordova Settings File.pdf' > /dev/null 2>> $(PKG_ERROR_LOG)
 	@$(WKHTMLTOPDF) --footer-center "Cordova ${CDV_VER} JavaScript Exception Logging" CordovaInstaller/docs/exception_logging.html
'dist/files/Guides/Cordova JavaScript Exception Logging.pdf' > /dev/null 2>> $(PKG_ERROR_LOG)
+	@$(WKHTMLTOPDF) --footer-center "Cordova ${CDV_VER} Custom URL Scheme Handling" CordovaInstaller/docs/custom_url_scheme.html
'dist/files/Guides/Cordova Custom URL Scheme Handling.pdf' > /dev/null 2>> $(PKG_ERROR_LOG)
 	@textutil -convert html -font 'Courier New' LICENSE -output CordovaInstaller/docs/LICENSE.html
> /dev/null 2>> $(PKG_ERROR_LOG)
 	@textutil -cat html CordovaInstaller/docs/finishup.html CordovaInstaller/docs/readme.html
CordovaInstaller/docs/LICENSE.html -output dist/files/Readme.html > /dev/null 2>>
 	@$(WKHTMLTOPDF) --footer-center "Cordova ${CDV_VER} Readme" dist/files/Readme.html dist/files/Readme.pdf
> /dev/null 2>> $(PKG_ERROR_LOG)
@@ -313,3 +314,7 @@ md-to-html: check-markdown
 	@echo '<html><body style="font-family: Helvetica Neue;font-size:10pt;">' >
 	@$(MARKDOWN) 'guides/Cordova JavaScript Exception' >> CordovaInstaller/docs/exception_logging.html
 	@echo '</body></html>'  >> CordovaInstaller/docs/exception_logging.html
+	@# generate 'Cordova Custom URL Scheme Handling' html from markdown
+	@echo '<html><body style="font-family: Helvetica Neue;font-size:10pt;">' >
+	@$(MARKDOWN) 'guides/Cordova Custom URL Scheme' >> CordovaInstaller/docs/custom_url_scheme.html
+	@echo '</body></html>'  >> CordovaInstaller/docs/custom_url_scheme.html
Custom URL Scheme
diff --git a/guides/Cordova Custom URL Scheme b/guides/Cordova Custom URL Scheme
new file mode 100644
index 0000000..e7c9c99
--- /dev/null
+++ b/guides/Cordova Custom URL Scheme	
@@ -0,0 +1,44 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+#  KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+# Cordova Custom URL Scheme Handling #
+For an iOS app, you can add a URL Scheme handler in your app's Info.plist so that your app
launches when another iOS app (like Mobile Safari) launches a URL with your custom scheme.
+1. Register your custom scheme in your app's Info.plist: the instructions are [here](
+2. In your JavaScript, add a global function **handleOpenURL** which just takes one parameter,
which will be a string containing the URL that was launched. Add your code to parse and handle
the URL in that global function. This function will be called always if your app was launched
from the custom scheme.
+        function handleOpenURL(url) {
+            // TODO: parse the url, and do something 
+        }
+3. In your JavaScript, the global variable **invokeString** will be set with the URL that
your app was launched with **if it was first launched with a URL (from a terminated state)**,
not from resuming from the background (multi-tasking).
+You **cannot** launch any interactive features like alerts in the **handleOpenURL** code,
if you do, your app will hang. Similarly, you should not call any Cordova APIs in there, unless
you wrap it first in a setTimeout call, with a timeout value of zero:
+        function handleOpenUrl(url) {
+             // TODO: parse the url, and do something 
+             setTimeout(function() {
+                 // TODO: call some Cordova API here
+             }, 0);
+        }
\ No newline at end of file

View raw message