@capacitor-firebase/functions 6.0.0-dev.59ed099.1719590033
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CapacitorFirebaseFunctions.podspec +19 -0
- package/README.md +167 -0
- package/android/build.gradle +60 -0
- package/android/src/main/AndroidManifest.xml +2 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/FirebaseFunctions.java +67 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/FirebaseFunctionsPlugin.java +91 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/options/CallByNameOptions.java +29 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/options/CallByUrlOptions.java +19 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/options/CallOptions.java +18 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/classes/results/CallResult.java +67 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/interfaces/EmptyResultCallback.java +5 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/interfaces/NonEmptyResultCallback.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/interfaces/Result.java +7 -0
- package/android/src/main/java/io/capawesome/capacitorjs/plugins/firebase/functions/interfaces/ResultCallback.java +5 -0
- package/android/src/main/res/.gitkeep +0 -0
- package/dist/docs.json +195 -0
- package/dist/esm/definitions.d.ts +75 -0
- package/dist/esm/definitions.js +2 -0
- package/dist/esm/definitions.js.map +1 -0
- package/dist/esm/index.d.ts +4 -0
- package/dist/esm/index.js +7 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/web.d.ts +6 -0
- package/dist/esm/web.js +21 -0
- package/dist/esm/web.js.map +1 -0
- package/dist/plugin.cjs.js +37 -0
- package/dist/plugin.cjs.js.map +1 -0
- package/dist/plugin.js +39 -0
- package/dist/plugin.js.map +1 -0
- package/ios/Plugin/Classes/Options/CallByNameOptions.swift +20 -0
- package/ios/Plugin/Classes/Options/CallByUrlOptions.swift +14 -0
- package/ios/Plugin/Classes/Options/CallOptions.swift +13 -0
- package/ios/Plugin/Classes/Results/CallResult.swift +26 -0
- package/ios/Plugin/FirebaseFunctions.swift +53 -0
- package/ios/Plugin/FirebaseFunctionsPlugin.h +10 -0
- package/ios/Plugin/FirebaseFunctionsPlugin.m +9 -0
- package/ios/Plugin/FirebaseFunctionsPlugin.swift +60 -0
- package/ios/Plugin/Info.plist +24 -0
- package/ios/Plugin/Protocols/Result.swift +6 -0
- package/package.json +99 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
require 'json'
|
|
2
|
+
|
|
3
|
+
package = JSON.parse(File.read(File.join(__dir__, 'package.json')))
|
|
4
|
+
|
|
5
|
+
Pod::Spec.new do |s|
|
|
6
|
+
s.name = 'CapacitorFirebaseFunctions'
|
|
7
|
+
s.version = package['version']
|
|
8
|
+
s.summary = package['description']
|
|
9
|
+
s.license = package['license']
|
|
10
|
+
s.homepage = package['repository']['url']
|
|
11
|
+
s.author = package['author']
|
|
12
|
+
s.source = { :git => package['repository']['url'], :tag => s.version.to_s }
|
|
13
|
+
s.source_files = 'ios/Plugin/**/*.{swift,h,m,c,cc,mm,cpp}'
|
|
14
|
+
s.ios.deployment_target = '13.0'
|
|
15
|
+
s.dependency 'Capacitor'
|
|
16
|
+
s.dependency 'FirebaseFunctions', '~> 10.25'
|
|
17
|
+
s.swift_version = '5.1'
|
|
18
|
+
s.static_framework = true
|
|
19
|
+
end
|
package/README.md
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
# @capacitor-firebase/functions
|
|
2
|
+
|
|
3
|
+
Unofficial Capacitor plugin for [Firebase Cloud Functions](https://firebase.google.com/docs/functions/).[^1]
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @capacitor-firebase/functions
|
|
9
|
+
npx cap sync
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Add Firebase to your project if you haven't already ([Android](https://firebase.google.com/docs/android/setup) / [iOS](https://firebase.google.com/docs/ios/setup)).
|
|
13
|
+
|
|
14
|
+
### Android
|
|
15
|
+
|
|
16
|
+
#### Variables
|
|
17
|
+
|
|
18
|
+
This plugin will use the following project variables (defined in your app’s `variables.gradle` file):
|
|
19
|
+
|
|
20
|
+
- `$firebaseFunctionsVersion` version of `com.google.firebase:firebase-functions` (default: `20.4.0`)
|
|
21
|
+
|
|
22
|
+
## Configuration
|
|
23
|
+
|
|
24
|
+
No configuration required for this plugin.
|
|
25
|
+
|
|
26
|
+
## Demo
|
|
27
|
+
|
|
28
|
+
A working example can be found here: [robingenz/capacitor-firebase-plugin-demo](https://github.com/robingenz/capacitor-firebase-plugin-demo)
|
|
29
|
+
|
|
30
|
+
## Usage
|
|
31
|
+
|
|
32
|
+
```typescript
|
|
33
|
+
import { FirebaseFunctions } from '@capacitor-firebase/functions';
|
|
34
|
+
|
|
35
|
+
const callByName = async () => {
|
|
36
|
+
const { data } = await FirebaseFunctions.callByName({
|
|
37
|
+
name: 'helloWorld',
|
|
38
|
+
data: {
|
|
39
|
+
string: 'Hello World!',
|
|
40
|
+
number: 123,
|
|
41
|
+
boolean: true,
|
|
42
|
+
array: [1, 2, 3],
|
|
43
|
+
object: {
|
|
44
|
+
key: 'value'
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
});
|
|
48
|
+
return data;
|
|
49
|
+
};
|
|
50
|
+
|
|
51
|
+
const callByUrl = async () => {
|
|
52
|
+
const { data } = await FirebaseFunctions.callByUrl({
|
|
53
|
+
url: 'https://us-central1-YOUR_PROJECT_ID.cloudfunctions.net/helloWorld',
|
|
54
|
+
data: {
|
|
55
|
+
string: 'Hello World!',
|
|
56
|
+
number: 123,
|
|
57
|
+
boolean: true,
|
|
58
|
+
array: [1, 2, 3],
|
|
59
|
+
object: {
|
|
60
|
+
key: 'value'
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
});
|
|
64
|
+
return data;
|
|
65
|
+
};
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
## API
|
|
69
|
+
|
|
70
|
+
<docgen-index>
|
|
71
|
+
|
|
72
|
+
* [`callByName(...)`](#callbyname)
|
|
73
|
+
* [`callByUrl(...)`](#callbyurl)
|
|
74
|
+
* [Interfaces](#interfaces)
|
|
75
|
+
* [Type Aliases](#type-aliases)
|
|
76
|
+
|
|
77
|
+
</docgen-index>
|
|
78
|
+
|
|
79
|
+
<docgen-api>
|
|
80
|
+
<!--Update the source file JSDoc comments and rerun docgen to update the docs below-->
|
|
81
|
+
|
|
82
|
+
### callByName(...)
|
|
83
|
+
|
|
84
|
+
```typescript
|
|
85
|
+
callByName(options: CallByNameOptions) => Promise<CallByNameResult>
|
|
86
|
+
```
|
|
87
|
+
|
|
88
|
+
Call a callable function by name.
|
|
89
|
+
|
|
90
|
+
| Param | Type |
|
|
91
|
+
| ------------- | --------------------------------------------------------------- |
|
|
92
|
+
| **`options`** | <code><a href="#callbynameoptions">CallByNameOptions</a></code> |
|
|
93
|
+
|
|
94
|
+
**Returns:** <code>Promise<<a href="#callresult">CallResult</a>></code>
|
|
95
|
+
|
|
96
|
+
**Since:** 6.1.0
|
|
97
|
+
|
|
98
|
+
--------------------
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
### callByUrl(...)
|
|
102
|
+
|
|
103
|
+
```typescript
|
|
104
|
+
callByUrl(options: CallByUrlOptions) => Promise<CallByUrlResult>
|
|
105
|
+
```
|
|
106
|
+
|
|
107
|
+
Call a callable function by URL.
|
|
108
|
+
|
|
109
|
+
| Param | Type |
|
|
110
|
+
| ------------- | ------------------------------------------------------------- |
|
|
111
|
+
| **`options`** | <code><a href="#callbyurloptions">CallByUrlOptions</a></code> |
|
|
112
|
+
|
|
113
|
+
**Returns:** <code>Promise<<a href="#callresult">CallResult</a>></code>
|
|
114
|
+
|
|
115
|
+
**Since:** 6.1.0
|
|
116
|
+
|
|
117
|
+
--------------------
|
|
118
|
+
|
|
119
|
+
|
|
120
|
+
### Interfaces
|
|
121
|
+
|
|
122
|
+
|
|
123
|
+
#### CallResult
|
|
124
|
+
|
|
125
|
+
| Prop | Type | Description | Since |
|
|
126
|
+
| ---------- | ---------------- | ------------------------------------ | ----- |
|
|
127
|
+
| **`data`** | <code>any</code> | The result of the callable function. | 6.1.0 |
|
|
128
|
+
|
|
129
|
+
|
|
130
|
+
#### CallByNameOptions
|
|
131
|
+
|
|
132
|
+
| Prop | Type | Description | Since |
|
|
133
|
+
| ------------ | ------------------- | ------------------------------------ | ----- |
|
|
134
|
+
| **`name`** | <code>string</code> | The name of the callable function. | 6.1.0 |
|
|
135
|
+
| **`region`** | <code>string</code> | The region of the callable function. | 6.1.0 |
|
|
136
|
+
|
|
137
|
+
|
|
138
|
+
#### CallByUrlOptions
|
|
139
|
+
|
|
140
|
+
| Prop | Type | Description | Since |
|
|
141
|
+
| --------- | ------------------- | --------------------------------- | ----- |
|
|
142
|
+
| **`url`** | <code>string</code> | The URL of the callable function. | 6.1.0 |
|
|
143
|
+
|
|
144
|
+
|
|
145
|
+
### Type Aliases
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
#### CallByNameResult
|
|
149
|
+
|
|
150
|
+
<code><a href="#callresult">CallResult</a></code>
|
|
151
|
+
|
|
152
|
+
|
|
153
|
+
#### CallByUrlResult
|
|
154
|
+
|
|
155
|
+
<code><a href="#callresult">CallResult</a></code>
|
|
156
|
+
|
|
157
|
+
</docgen-api>
|
|
158
|
+
|
|
159
|
+
## Changelog
|
|
160
|
+
|
|
161
|
+
See [CHANGELOG.md](https://github.com/capawesome-team/capacitor-firebase/blob/main/packages/functions/CHANGELOG.md).
|
|
162
|
+
|
|
163
|
+
## License
|
|
164
|
+
|
|
165
|
+
See [LICENSE](https://github.com/capawesome-team/capacitor-firebase/blob/main/packages/functions/LICENSE).
|
|
166
|
+
|
|
167
|
+
[^1]: This project is not affiliated with, endorsed by, sponsored by, or approved by Google LLC or any of their affiliates or subsidiaries.
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
ext {
|
|
2
|
+
junitVersion = project.hasProperty('junitVersion') ? rootProject.ext.junitVersion : '4.13.2'
|
|
3
|
+
androidxAppCompatVersion = project.hasProperty('androidxAppCompatVersion') ? rootProject.ext.androidxAppCompatVersion : '1.6.1'
|
|
4
|
+
androidxJunitVersion = project.hasProperty('androidxJunitVersion') ? rootProject.ext.androidxJunitVersion : '1.1.5'
|
|
5
|
+
androidxEspressoCoreVersion = project.hasProperty('androidxEspressoCoreVersion') ? rootProject.ext.androidxEspressoCoreVersion : '3.5.1'
|
|
6
|
+
firebaseFunctionsVersion = project.hasProperty('firebaseFunctionsVersion') ? rootProject.ext.firebaseFunctionsVersion : '20.4.0'
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
buildscript {
|
|
10
|
+
repositories {
|
|
11
|
+
google()
|
|
12
|
+
mavenCentral()
|
|
13
|
+
}
|
|
14
|
+
dependencies {
|
|
15
|
+
classpath 'com.android.tools.build:gradle:8.2.1'
|
|
16
|
+
}
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
apply plugin: 'com.android.library'
|
|
20
|
+
|
|
21
|
+
android {
|
|
22
|
+
namespace "io.capawesome.capacitorjs.plugins.firebase.functions"
|
|
23
|
+
compileSdk project.hasProperty('compileSdkVersion') ? rootProject.ext.compileSdkVersion : 34
|
|
24
|
+
defaultConfig {
|
|
25
|
+
minSdkVersion project.hasProperty('minSdkVersion') ? rootProject.ext.minSdkVersion : 22
|
|
26
|
+
targetSdkVersion project.hasProperty('targetSdkVersion') ? rootProject.ext.targetSdkVersion : 34
|
|
27
|
+
versionCode 1
|
|
28
|
+
versionName "1.0"
|
|
29
|
+
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
|
30
|
+
}
|
|
31
|
+
buildTypes {
|
|
32
|
+
release {
|
|
33
|
+
minifyEnabled false
|
|
34
|
+
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
lintOptions {
|
|
38
|
+
abortOnError false
|
|
39
|
+
}
|
|
40
|
+
compileOptions {
|
|
41
|
+
sourceCompatibility JavaVersion.VERSION_17
|
|
42
|
+
targetCompatibility JavaVersion.VERSION_17
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
repositories {
|
|
47
|
+
google()
|
|
48
|
+
mavenCentral()
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
dependencies {
|
|
53
|
+
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
|
54
|
+
implementation project(':capacitor-android')
|
|
55
|
+
implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
|
|
56
|
+
implementation "com.google.firebase:firebase-functions:$firebaseFunctionsVersion"
|
|
57
|
+
testImplementation "junit:junit:$junitVersion"
|
|
58
|
+
androidTestImplementation "androidx.test.ext:junit:$androidxJunitVersion"
|
|
59
|
+
androidTestImplementation "androidx.test.espresso:espresso-core:$androidxEspressoCoreVersion"
|
|
60
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.firebase.functions;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.options.CallByNameOptions;
|
|
7
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.options.CallByUrlOptions;
|
|
8
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.results.CallResult;
|
|
9
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.interfaces.NonEmptyResultCallback;
|
|
10
|
+
|
|
11
|
+
public class FirebaseFunctions {
|
|
12
|
+
|
|
13
|
+
private FirebaseFunctionsPlugin plugin;
|
|
14
|
+
|
|
15
|
+
public FirebaseFunctions(FirebaseFunctionsPlugin plugin) {
|
|
16
|
+
this.plugin = plugin;
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
public void callByName(@NonNull CallByNameOptions options, @NonNull NonEmptyResultCallback callback) {
|
|
20
|
+
String name = options.getName();
|
|
21
|
+
String region = options.getRegion();
|
|
22
|
+
Object data = options.getData();
|
|
23
|
+
|
|
24
|
+
getFirebaseFunctionsInstance(region)
|
|
25
|
+
.getHttpsCallable(name)
|
|
26
|
+
.call(data)
|
|
27
|
+
.addOnSuccessListener(
|
|
28
|
+
task -> {
|
|
29
|
+
CallResult result = new CallResult(task.getData());
|
|
30
|
+
callback.success(result);
|
|
31
|
+
}
|
|
32
|
+
)
|
|
33
|
+
.addOnFailureListener(
|
|
34
|
+
exception -> {
|
|
35
|
+
callback.error(exception);
|
|
36
|
+
}
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
public void callByUrl(@NonNull CallByUrlOptions options, @NonNull NonEmptyResultCallback callback) {
|
|
41
|
+
String url = options.getUrl();
|
|
42
|
+
Object data = options.getData();
|
|
43
|
+
|
|
44
|
+
getFirebaseFunctionsInstance(null)
|
|
45
|
+
.getHttpsCallable(url)
|
|
46
|
+
.call(data)
|
|
47
|
+
.addOnSuccessListener(
|
|
48
|
+
task -> {
|
|
49
|
+
CallResult result = new CallResult(task.getData());
|
|
50
|
+
callback.success(result);
|
|
51
|
+
}
|
|
52
|
+
)
|
|
53
|
+
.addOnFailureListener(
|
|
54
|
+
exception -> {
|
|
55
|
+
callback.error(exception);
|
|
56
|
+
}
|
|
57
|
+
);
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
private com.google.firebase.functions.FirebaseFunctions getFirebaseFunctionsInstance(@Nullable String regionOrCustomDomain) {
|
|
61
|
+
if (regionOrCustomDomain == null) {
|
|
62
|
+
return com.google.firebase.functions.FirebaseFunctions.getInstance();
|
|
63
|
+
} else {
|
|
64
|
+
return com.google.firebase.functions.FirebaseFunctions.getInstance(regionOrCustomDomain);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
}
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.firebase.functions;
|
|
2
|
+
|
|
3
|
+
import com.getcapacitor.JSObject;
|
|
4
|
+
import com.getcapacitor.Logger;
|
|
5
|
+
import com.getcapacitor.Plugin;
|
|
6
|
+
import com.getcapacitor.PluginCall;
|
|
7
|
+
import com.getcapacitor.PluginMethod;
|
|
8
|
+
import com.getcapacitor.annotation.CapacitorPlugin;
|
|
9
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.options.CallByNameOptions;
|
|
10
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.classes.options.CallByUrlOptions;
|
|
11
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.interfaces.NonEmptyResultCallback;
|
|
12
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.interfaces.Result;
|
|
13
|
+
|
|
14
|
+
@CapacitorPlugin(name = "FirebaseFunctions")
|
|
15
|
+
public class FirebaseFunctionsPlugin extends Plugin {
|
|
16
|
+
|
|
17
|
+
public static final String TAG = "FirebaseFunctions";
|
|
18
|
+
public static final String ERROR_NAME_MISSING = "name must be provided.";
|
|
19
|
+
public static final String ERROR_URL_MISSING = "url must be provided.";
|
|
20
|
+
|
|
21
|
+
private FirebaseFunctions implementation;
|
|
22
|
+
|
|
23
|
+
public void load() {
|
|
24
|
+
implementation = new FirebaseFunctions(this);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
@PluginMethod
|
|
28
|
+
public void callByName(PluginCall call) {
|
|
29
|
+
try {
|
|
30
|
+
JSObject json = call.getData();
|
|
31
|
+
String name = json.getString("name", null);
|
|
32
|
+
if (name == null) {
|
|
33
|
+
call.reject(ERROR_NAME_MISSING);
|
|
34
|
+
return;
|
|
35
|
+
}
|
|
36
|
+
String region = json.getString("region", null);
|
|
37
|
+
Object data = json.opt("data");
|
|
38
|
+
|
|
39
|
+
CallByNameOptions options = new CallByNameOptions(name, region, data);
|
|
40
|
+
NonEmptyResultCallback callback = new NonEmptyResultCallback() {
|
|
41
|
+
@Override
|
|
42
|
+
public void success(Result result) {
|
|
43
|
+
call.resolve(result.toJSObject());
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
@Override
|
|
47
|
+
public void error(Exception exception) {
|
|
48
|
+
Logger.error(TAG, exception.getMessage(), exception);
|
|
49
|
+
call.reject(exception.getMessage());
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
implementation.callByName(options, callback);
|
|
54
|
+
} catch (Exception exception) {
|
|
55
|
+
Logger.error(TAG, exception.getMessage(), exception);
|
|
56
|
+
call.reject(exception.getMessage());
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
@PluginMethod
|
|
61
|
+
public void callByUrl(PluginCall call) {
|
|
62
|
+
try {
|
|
63
|
+
JSObject json = call.getData();
|
|
64
|
+
String url = json.getString("url");
|
|
65
|
+
if (url == null) {
|
|
66
|
+
call.reject(ERROR_URL_MISSING);
|
|
67
|
+
return;
|
|
68
|
+
}
|
|
69
|
+
Object data = json.opt("data");
|
|
70
|
+
|
|
71
|
+
CallByUrlOptions options = new CallByUrlOptions(url, data);
|
|
72
|
+
NonEmptyResultCallback callback = new NonEmptyResultCallback() {
|
|
73
|
+
@Override
|
|
74
|
+
public void success(Result result) {
|
|
75
|
+
call.resolve(result.toJSObject());
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
@Override
|
|
79
|
+
public void error(Exception exception) {
|
|
80
|
+
Logger.error(TAG, exception.getMessage(), exception);
|
|
81
|
+
call.reject(exception.getMessage());
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
implementation.callByUrl(options, callback);
|
|
86
|
+
} catch (Exception exception) {
|
|
87
|
+
Logger.error(TAG, exception.getMessage(), exception);
|
|
88
|
+
call.reject(exception.getMessage());
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
}
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.firebase.functions.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
|
|
6
|
+
public class CallByNameOptions extends CallOptions {
|
|
7
|
+
|
|
8
|
+
@NonNull
|
|
9
|
+
private String name;
|
|
10
|
+
|
|
11
|
+
@Nullable
|
|
12
|
+
private String region;
|
|
13
|
+
|
|
14
|
+
public CallByNameOptions(@NonNull String name, @Nullable String region, Object data) {
|
|
15
|
+
super(data);
|
|
16
|
+
this.name = name;
|
|
17
|
+
this.region = region;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@NonNull
|
|
21
|
+
public String getName() {
|
|
22
|
+
return name;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
@Nullable
|
|
26
|
+
public String getRegion() {
|
|
27
|
+
return region;
|
|
28
|
+
}
|
|
29
|
+
}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.firebase.functions.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
|
|
5
|
+
public class CallByUrlOptions extends CallOptions {
|
|
6
|
+
|
|
7
|
+
@NonNull
|
|
8
|
+
private String url;
|
|
9
|
+
|
|
10
|
+
public CallByUrlOptions(@NonNull String url, Object data) {
|
|
11
|
+
super(data);
|
|
12
|
+
this.url = url;
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
@NonNull
|
|
16
|
+
public String getUrl() {
|
|
17
|
+
return url;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.firebase.functions.classes.options;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.Nullable;
|
|
4
|
+
|
|
5
|
+
public class CallOptions {
|
|
6
|
+
|
|
7
|
+
@Nullable
|
|
8
|
+
private Object data;
|
|
9
|
+
|
|
10
|
+
public CallOptions(@Nullable Object data) {
|
|
11
|
+
this.data = data;
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
@Nullable
|
|
15
|
+
public Object getData() {
|
|
16
|
+
return data;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
package io.capawesome.capacitorjs.plugins.firebase.functions.classes.results;
|
|
2
|
+
|
|
3
|
+
import androidx.annotation.NonNull;
|
|
4
|
+
import androidx.annotation.Nullable;
|
|
5
|
+
import com.getcapacitor.JSArray;
|
|
6
|
+
import com.getcapacitor.JSObject;
|
|
7
|
+
import io.capawesome.capacitorjs.plugins.firebase.functions.interfaces.Result;
|
|
8
|
+
import java.util.ArrayList;
|
|
9
|
+
import java.util.Map;
|
|
10
|
+
|
|
11
|
+
public class CallResult implements Result {
|
|
12
|
+
|
|
13
|
+
@Nullable
|
|
14
|
+
private Object data;
|
|
15
|
+
|
|
16
|
+
public CallResult(@Nullable Object data) {
|
|
17
|
+
this.data = data;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
@NonNull
|
|
21
|
+
public JSObject toJSObject() {
|
|
22
|
+
Object dataResult = CallResult.createJSValue(data);
|
|
23
|
+
|
|
24
|
+
JSObject result = new JSObject();
|
|
25
|
+
result.put("data", dataResult);
|
|
26
|
+
return result;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
@Nullable
|
|
30
|
+
private static Object createJSValue(@Nullable Object object) {
|
|
31
|
+
if (object instanceof Map) {
|
|
32
|
+
return createJSObjectFromMap((Map<String, Object>) object);
|
|
33
|
+
} else if (object instanceof ArrayList) {
|
|
34
|
+
return createJSArrayFromArrayList((ArrayList) object);
|
|
35
|
+
}
|
|
36
|
+
return object;
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
@Nullable
|
|
40
|
+
private static JSObject createJSObjectFromMap(@Nullable Map<String, Object> map) {
|
|
41
|
+
if (map == null) {
|
|
42
|
+
return null;
|
|
43
|
+
}
|
|
44
|
+
JSObject object = new JSObject();
|
|
45
|
+
for (String key : map.keySet()) {
|
|
46
|
+
Object value = map.get(key);
|
|
47
|
+
if (value instanceof ArrayList) {
|
|
48
|
+
value = createJSArrayFromArrayList((ArrayList) value);
|
|
49
|
+
} else if (value instanceof Map) {
|
|
50
|
+
value = createJSObjectFromMap((Map<String, Object>) value);
|
|
51
|
+
}
|
|
52
|
+
object.put(key, value);
|
|
53
|
+
}
|
|
54
|
+
return object;
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
private static JSArray createJSArrayFromArrayList(ArrayList arrayList) {
|
|
58
|
+
JSArray array = new JSArray();
|
|
59
|
+
for (Object value : arrayList) {
|
|
60
|
+
if (value instanceof Map) {
|
|
61
|
+
value = createJSObjectFromMap((Map<String, Object>) value);
|
|
62
|
+
}
|
|
63
|
+
array.put(value);
|
|
64
|
+
}
|
|
65
|
+
return array;
|
|
66
|
+
}
|
|
67
|
+
}
|
|
File without changes
|