Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#128 Fixed openAppSettings on iOS #133

Merged
merged 6 commits into from
Oct 17, 2024
Merged
Show file tree
Hide file tree
Changes from 4 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
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ The full list can be found in `dev.icerock.moko.permissions.Permission` enum.
* Bluetooth Scan: **Permission.BLUETOOTH_SCAN**
* Bluetooth Connect: **Permission.BLUETOOTH_CONNECT**
* Bluetooth Advertise: **Permission.BLUETOOTH_ADVERTISE**
* Contacts: **Permission.CONTACTS**
* Motion: **Permission.MOTION**

## Usage
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class PermissionsController : PermissionsControllerProtocol {

override fun openAppSettings() {
val settingsUrl: NSURL = NSURL.URLWithString(UIApplicationOpenSettingsURLString)!!
UIApplication.sharedApplication.openURL(settingsUrl)
UIApplication.sharedApplication.openURL(settingsUrl, mapOf<Any?, Any>(), null)
}

private fun getDelegate(permission: Permission): PermissionDelegate {
Expand Down
22 changes: 16 additions & 6 deletions sample/ios-app/src/Resources/Base.lproj/Main.storyboard
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="14490.70" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="zIh-nI-gcX">
<device id="retina4_0" orientation="portrait">
<adaptation id="fullscreen"/>
</device>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" useTraitCollections="YES" colorMatched="YES" initialViewController="zIh-nI-gcX">
<device id="retina4_0" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="14490.49"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
Expand Down Expand Up @@ -37,7 +35,7 @@
<rect key="frame" x="0.0" y="0.0" width="320" height="568"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<subviews>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="roundedRect" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wrA-Wa-jvv">
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="wrA-Wa-jvv">
<rect key="frame" x="128" y="269" width="64" height="30"/>
<state key="normal" title="Press me"/>
<connections>
Expand All @@ -50,12 +48,24 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<button opaque="NO" contentMode="scaleToFill" contentHorizontalAlignment="center" contentVerticalAlignment="center" buttonType="system" lineBreakMode="middleTruncation" translatesAutoresizingMaskIntoConstraints="NO" id="jlX-n2-E1L">
<rect key="frame" x="102" y="222" width="116.5" height="31"/>
<state key="normal" title="Button"/>
<buttonConfiguration key="configuration" style="plain" title="Open Settings">
<fontDescription key="titleFontDescription" type="system" pointSize="14"/>
</buttonConfiguration>
<connections>
<action selector="onOpenSettingsPressed" destination="TTy-86-aNs" eventType="touchUpInside" id="8gX-ul-uJn"/>
</connections>
</button>
</subviews>
<color key="backgroundColor" white="1" alpha="1" colorSpace="custom" customColorSpace="genericGamma22GrayColorSpace"/>
<constraints>
<constraint firstItem="wrA-Wa-jvv" firstAttribute="centerY" secondItem="KxK-oh-5KO" secondAttribute="centerY" id="0g2-Uu-Q0F"/>
<constraint firstItem="wrA-Wa-jvv" firstAttribute="centerX" secondItem="KxK-oh-5KO" secondAttribute="centerX" id="FGq-2f-QAF"/>
<constraint firstItem="wrA-Wa-jvv" firstAttribute="top" secondItem="jlX-n2-E1L" secondAttribute="bottom" constant="16" id="Qps-Mk-tYJ"/>
<constraint firstItem="SC7-EO-Tfy" firstAttribute="centerX" secondItem="KxK-oh-5KO" secondAttribute="centerX" id="Qw1-Gl-wBe"/>
<constraint firstItem="jlX-n2-E1L" firstAttribute="centerX" secondItem="KxK-oh-5KO" secondAttribute="centerX" id="WvE-2P-C0q"/>
<constraint firstItem="SC7-EO-Tfy" firstAttribute="top" secondItem="wrA-Wa-jvv" secondAttribute="bottom" constant="8" id="hoL-Vh-IjN"/>
</constraints>
</view>
Expand Down
4 changes: 4 additions & 0 deletions sample/ios-app/src/TestViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,10 @@ class TestViewController: UIViewController {
@IBAction func onPermissionPressed() {
viewModel.onRequestPermissionButtonPressed()
}

@IBAction func onOpenSettingsPressed() {
PermissionsController().openAppSettings()
}
}

extension TestViewController: SampleViewModelEventListener {
Expand Down
Loading