Skip to content

Commit 77404c5

Browse files
committed
feat(plugins): add iOS support for various plugins and implement Browser functionality
Signed-off-by: 7HR4IZ3 <90985774+7HR4IZ3@users.noreply.github.com>
1 parent 1207f64 commit 77404c5

32 files changed

Lines changed: 2414 additions & 40 deletions

File tree

setup-ios.sh

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
#!/usr/bin/env bash
2+
set -euo pipefail
3+
4+
if [[ "$(uname -s)" != "Darwin" ]]; then
5+
echo "This script is intended for macOS with Xcode installed."
6+
exit 1
7+
fi
8+
9+
if ! xcode-select -p >/dev/null 2>&1; then
10+
echo "Xcode Command Line Tools are not installed."
11+
echo "Run: xcode-select --install"
12+
exit 1
13+
fi
14+
15+
if ! xcodebuild -version >/dev/null 2>&1; then
16+
echo "Xcode is not installed or not configured."
17+
echo "Install Xcode from the App Store and run: sudo xcode-select -s /Applications/Xcode.app/Contents/Developer"
18+
exit 1
19+
fi
20+
21+
sudo xcodebuild -license accept >/dev/null
22+
23+
if ! command -v brew >/dev/null 2>&1; then
24+
echo "Homebrew not found. Install it from https://brew.sh and re-run this script."
25+
exit 1
26+
fi
27+
28+
brew update
29+
brew install cocoapods ios-deploy
30+
31+
pod repo update
32+
33+
echo "iOS tooling setup complete."
34+
35+
if ! command -v cordova >/dev/null 2>&1; then
36+
echo "Cordova CLI not found. Install with: npm install -g cordova"
37+
fi

src/plugins/browser/ios/Browser.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#import <Cordova/CDVPlugin.h>
2+
3+
@interface Browser : CDVPlugin
4+
- (void)open:(CDVInvokedUrlCommand *)command;
5+
@end

src/plugins/browser/ios/Browser.m

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
#import "Browser.h"
2+
#import <SafariServices/SafariServices.h>
3+
#import <UIKit/UIKit.h>
4+
5+
@implementation Browser
6+
7+
- (void)open:(CDVInvokedUrlCommand *)command {
8+
NSString *urlString = command.arguments.count > 0 ? command.arguments[0] : @"";
9+
NSURL *url = [NSURL URLWithString:urlString];
10+
if (!url) {
11+
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_ERROR messageAsString:@"Invalid URL"];
12+
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
13+
return;
14+
}
15+
16+
dispatch_async(dispatch_get_main_queue(), ^{
17+
if (@available(iOS 9.0, *)) {
18+
SFSafariViewController *safari = [[SFSafariViewController alloc] initWithURL:url];
19+
[self.viewController presentViewController:safari animated:YES completion:nil];
20+
} else {
21+
[[UIApplication sharedApplication] openURL:url];
22+
}
23+
});
24+
25+
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK];
26+
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
27+
}
28+
29+
@end

src/plugins/browser/plugin.xml

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
<description>In app browser</description>
66
<license>Apache 2.0</license>
77

8-
<platform name="android">
8+
<platform name="android">
99

1010
<config-file target="res/xml/config.xml" parent="/*">
1111
<feature name="Browser">
@@ -28,6 +28,17 @@
2828
<source-file src="android/com/foxdebug/browser/BrowserActivity.java" target-dir="src/com/foxdebug/browser"/>
2929
<source-file src="android/com/foxdebug/browser/Emulator.java" target-dir="src/com/foxdebug/browser"/>
3030
<source-file src="android/com/foxdebug/browser/Plugin.java" target-dir="src/com/foxdebug/browser"/>
31-
<source-file src="android/com/foxdebug/browser/Menu.java" target-dir="src/com/foxdebug/browser"/>
32-
</platform>
33-
</plugin>
31+
<source-file src="android/com/foxdebug/browser/Menu.java" target-dir="src/com/foxdebug/browser"/>
32+
</platform>
33+
34+
<platform name="ios">
35+
<config-file target="config.xml" parent="/*">
36+
<feature name="Browser">
37+
<param name="ios-package" value="Browser"/>
38+
</feature>
39+
</config-file>
40+
41+
<header-file src="ios/Browser.h"/>
42+
<source-file src="ios/Browser.m"/>
43+
</platform>
44+
</plugin>
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
#import <Cordova/CDVPlugin.h>
2+
3+
@interface CDVBuildInfo : CDVPlugin
4+
- (void)init:(CDVInvokedUrlCommand *)command;
5+
@end
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#import "CDVBuildInfo.h"
2+
3+
@implementation CDVBuildInfo
4+
5+
- (void)init:(CDVInvokedUrlCommand *)command {
6+
NSDictionary *info = [[NSBundle mainBundle] infoDictionary];
7+
NSString *bundleId = [[NSBundle mainBundle] bundleIdentifier] ?: @"";
8+
NSString *displayName = info[@"CFBundleDisplayName"] ?: info[@"CFBundleName"] ?: @"";
9+
NSString *name = info[@"CFBundleName"] ?: @"";
10+
NSString *version = info[@"CFBundleShortVersionString"] ?: @"";
11+
NSString *build = info[@"CFBundleVersion"] ?: @"";
12+
13+
#ifdef DEBUG
14+
NSNumber *debug = @YES;
15+
NSString *buildType = @"debug";
16+
#else
17+
NSNumber *debug = @NO;
18+
NSString *buildType = @"release";
19+
#endif
20+
21+
NSString *installDateString = @"";
22+
NSString *bundlePath = [[NSBundle mainBundle] bundlePath];
23+
NSDictionary *attrs = [[NSFileManager defaultManager] attributesOfItemAtPath:bundlePath error:nil];
24+
NSDate *installDate = attrs[NSFileCreationDate];
25+
if (installDate) {
26+
NSDateFormatter *formatter = [[NSDateFormatter alloc] init];
27+
formatter.locale = [NSLocale localeWithLocaleIdentifier:@"en_US_POSIX"];
28+
formatter.dateFormat = @"yyyy-MM-dd'T'HH:mm:ss.SSSZZZZZ";
29+
installDateString = [formatter stringFromDate:installDate] ?: @"";
30+
}
31+
32+
NSDictionary *payload = @{
33+
@"packageName": bundleId,
34+
@"basePackageName": bundleId,
35+
@"displayName": displayName,
36+
@"name": name,
37+
@"version": version,
38+
@"versionCode": build,
39+
@"debug": debug,
40+
@"buildType": buildType,
41+
@"flavor": @"",
42+
@"installDate": installDateString
43+
};
44+
45+
CDVPluginResult *result = [CDVPluginResult resultWithStatus:CDVCommandStatus_OK messageAsDictionary:payload];
46+
[self.commandDelegate sendPluginResult:result callbackId:command.callbackId];
47+
}
48+
49+
@end

src/plugins/ftp/plugin.xml

Lines changed: 23 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -11,15 +11,26 @@
1111
</js-module>
1212

1313
<!-- android -->
14-
<platform name="android">
15-
<config-file target="res/xml/config.xml" parent="/*">
16-
<feature name="Ftp">
17-
<param name="android-package" value="com.foxdebug.ftp.Ftp" />
18-
</feature>
19-
</config-file>
20-
21-
<source-file src="src/android/com/foxdebug/ftp/Ftp.java" target-dir="src/com/foxdebug/ftp" />
22-
<framework src="commons-net:commons-net:3.12.0" />
23-
</platform>
24-
25-
</plugin>
14+
<platform name="android">
15+
<config-file target="res/xml/config.xml" parent="/*">
16+
<feature name="Ftp">
17+
<param name="android-package" value="com.foxdebug.ftp.Ftp" />
18+
</feature>
19+
</config-file>
20+
21+
<source-file src="src/android/com/foxdebug/ftp/Ftp.java" target-dir="src/com/foxdebug/ftp" />
22+
<framework src="commons-net:commons-net:3.12.0" />
23+
</platform>
24+
25+
<platform name="ios">
26+
<config-file target="config.xml" parent="/*">
27+
<feature name="Ftp">
28+
<param name="ios-package" value="Ftp" />
29+
</feature>
30+
</config-file>
31+
32+
<header-file src="src/ios/Ftp.h" />
33+
<source-file src="src/ios/Ftp.m" />
34+
<framework src="GRRequests" type="podspec" />
35+
</platform>
36+
</plugin>

src/plugins/ftp/src/ios/Ftp.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#import <Cordova/CDVPlugin.h>
2+
3+
@interface Ftp : CDVPlugin
4+
@end

0 commit comments

Comments
 (0)