apache / apache/cordova-ios

Pass Launch Parameters to Cordova App

Open
#723 9 comments 2 reactions 0 assignees View on GitHub
enhancement
Dominant language
JavaScript
Stars
2.2k
Forks
1k
Avg merge
12h 11m
Merged PRs (30d)
18

Description

# Feature Request

## Motivation Behind Feature
It is possible to launch an app with start-up parameters. This is useful for opening an app in a specific context. An example is opening an editor with a specific file. Unfortunately startup parameters currently are not passed to the Cordova app.

## Feature Description
An app can be launched with parameters: myapp?var1=foo

In the Cordova app, the parameters can be picked up:
var url = new URL(globalThis.location;);
var var1 = url.searchParams.get("var1");

## Alternatives or Workarounds
For IOS I currently copy this code in xCode manually to didFinishLaunchingWithOptions in CDVAppDelegate.m

// Set your app's start page by setting the tag in config.xml.
// If necessary, uncomment the line below to override it.
NSURL *url = launchOptions[UIApplicationLaunchOptionsURLKey];
if (url)
{
self.viewController.startPage = [@"index.html?" stringByAppendingString:url.query];
} else {
self.viewController.startPage = @"index.html";
}

It would be nice if this can become a part of the standard IOS implementation, and if a similar solution can be created for other platforms.

Contributor guide

Open the contributing guide

Research direction

Start with CDVAppDelegate.m and its didFinishLaunchingWithOptions implementation, then review how config.xml sets the content src and how the Cordova app receives its start page. Use the documented launch URL example and the existing iOS workaround as the behavioral reference. Done means startup query parameters are available to the Cordova app through the standard iOS implementation.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript, objective-c
Domain
mobile-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.