Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
73 changes: 73 additions & 0 deletions android/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
# Capacitor Android

The Capacitor Android package provides the Android runtime for Capacitor applications. It allows you to build and deploy your web application to Android devices and emulators.

## Installation

Install the android package:

```bash
npm install @capacitor/android
```

Add the Android platform to your Capacitor project:

```bash
npx cap add android
```

## Usage

### Opening the Android Project

To open your Android project in Android Studio:

```bash
npx cap open android
```

### Running on Device/Emulator

You can run your app directly from the command line:

```bash
npx cap run android
```

## Configuration

The Android configuration is handled primarily through `capacitor.config.ts` and the native `AndroidManifest.xml`.

### Permissions

Add permissions to your `android/app/src/main/AndroidManifest.xml` file as needed by your plugins.

```xml
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
```

## Version Compatibility

| Capacitor Version | Android Version | Gradle Version |
|------------------|-----------------|----------------|
| v6.x | Android 14+ | 8.2+ |
| v5.x | Android 13+ | 8.0+ |

## Local Development

If you're contributing to the Capacitor Android runtime:

1. Clone the repository
2. Open `android/` in Android Studio
3. Let Gradle sync and build the project

## Resources

- [Android Deployment Guide](https://capacitorjs.com/docs/android/deploy)
- [Troubleshooting Android](https://capacitorjs.com/docs/android/troubleshooting)
- [Capacitor Documentation](https://capacitorjs.com/docs)

## License

- [MIT](https://github.com/ionic-team/capacitor/blob/HEAD/LICENSE)
7 changes: 4 additions & 3 deletions core/native-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,11 +125,9 @@ const convertBody = async (
const CAPACITOR_HTTP_INTERCEPTOR = '/_capacitor_http_interceptor_';
const CAPACITOR_HTTP_INTERCEPTOR_URL_PARAM = 'u';

// TODO: export as Cap function
const isRelativeOrProxyUrl = (url: string | undefined): boolean =>
!url || !(url.startsWith('http:') || url.startsWith('https:')) || url.indexOf(CAPACITOR_HTTP_INTERCEPTOR) > -1;

// TODO: export as Cap function
const createProxyUrl = (url: string, win: WindowCapacitor): string => {
if (isRelativeOrProxyUrl(url)) return url;
const bridgeUrl = new URL(win.Capacitor?.getServerUrl() ?? '');
Expand Down Expand Up @@ -237,6 +235,9 @@ const initBridge = (w: any): void => {
return false;
};

cap.isRelativeOrProxyUrl = isRelativeOrProxyUrl;
cap.createProxyUrl = createProxyUrl;

win.Capacitor = cap;
};

Expand Down Expand Up @@ -604,7 +605,7 @@ const initBridge = (w: any): void => {

// XHR patch
interface PatchedXMLHttpRequestConstructor extends XMLHttpRequest {
new (): XMLHttpRequest;
new(): XMLHttpRequest;
}

window.XMLHttpRequest = function () {
Expand Down
10 changes: 10 additions & 0 deletions core/src/definitions-internal.ts
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,16 @@ export interface CapacitorInstance extends CapacitorGlobal {
* Low-level API used by the native bridge.
*/
withPlugin?: (pluginName: string, fn: (...args: any[]) => any) => void;

/**
* Checks if a URL is relative or a proxy URL.
*/
isRelativeOrProxyUrl: (url: string | undefined) => boolean;

/**
* Creates a proxy URL for the given URL.
*/
createProxyUrl: (url: string, win: WindowCapacitor) => string;
}

export interface MessageCallData {
Expand Down
75 changes: 75 additions & 0 deletions ios/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
# Capacitor iOS

The Capacitor iOS package provides the iOS runtime for Capacitor applications. It allows you to build and deploy your web application to iOS devices and simulators.

## Installation

Install the ios package:

```bash
npm install @capacitor/ios
```

Add the iOS platform to your Capacitor project:

```bash
npx cap add ios
```

## Usage

### Opening the iOS Project

To open your iOS project in Xcode:

```bash
npx cap open ios
```

### Running on Simulator/Device

You can run your app directly from the command line:

```bash
npx cap run ios
```

## Configuration

The iOS configuration is handled primarily through `capacitor.config.ts` and the native `Info.plist`.

### Permissions

Add usage descriptions to your `ios/App/App/Info.plist` file as needed by your plugins.

```xml
<key>NSCameraUsageDescription</key>
<string>We need access to the camera to take photos</string>
<key>NSLocationWhenInUseUsageDescription</key>
<string>We need your location to show local content</string>
```

## Version Compatibility

| Capacitor Version | iOS Version | Xcode Version |
|------------------|-------------|---------------|
| v6.x | iOS 13+ | 15.0+ |
| v5.x | iOS 13+ | 14.1+ |

## Local Development

If you're contributing to the Capacitor iOS runtime:

1. Clone the repository
2. Run `npm install` in the root
3. Open `ios/Capacitor/Capacitor.xcworkspace` in Xcode

## Resources

- [iOS Deployment Guide](https://capacitorjs.com/docs/ios/deploy)
- [Troubleshooting iOS](https://capacitorjs.com/docs/ios/troubleshooting)
- [Capacitor Documentation](https://capacitorjs.com/docs)

## License

- [MIT](https://github.com/ionic-team/capacitor/blob/HEAD/LICENSE)