Automatically switch back to previous app (if iOS has detected one) after A) WalletConnect session approval B) WalletConnect session rejection C) WalletConnect signing
parent
4d8e301ece
commit
ffce20f3ed
@ -0,0 +1,27 @@ |
||||
# |
||||
# Be sure to run `pod lib lint AlphaWalletGoBack.podspec' to ensure this is a |
||||
# valid spec before submitting. |
||||
# |
||||
# Any lines starting with a # are optional, but their use is encouraged |
||||
# To learn more about a Podspec see https://guides.cocoapods.org/syntax/podspec.html |
||||
# |
||||
|
||||
Pod::Spec.new do |s| |
||||
s.name = 'AlphaWalletGoBack' |
||||
s.version = '1.0.0' |
||||
s.summary = 'Alpha Wallet GoBack library' |
||||
s.description = <<-DESC |
||||
Lightweight library representing the AlphaWalletGoBack with its functionality |
||||
DESC |
||||
s.homepage = "https://github.com/AlphaWallet/alpha-wallet-ios/tree/master/modules/AlphaWalletGoBack" |
||||
s.license = { :type => 'MIT', :file => 'LICENSE' } |
||||
s.author = { "Hwee-Boon Yar" => "hboon@motionobj.com" } |
||||
s.ios.deployment_target = '12.0' |
||||
s.swift_version = '4.0' |
||||
s.platform = :ios, "12.0" |
||||
s.source = { :git => 'git@github.com:AlphaWallet/alpha-wallet-ios.git', :tag => "#{s.version}" } |
||||
s.source_files = 'AlphaWalletGoBack/**/*.{h,m}' |
||||
s.pod_target_xcconfig = { 'SWIFT_OPTIMIZATION_LEVEL' => '-Owholemodule' } |
||||
|
||||
s.frameworks = 'UIKit' |
||||
end |
@ -0,0 +1,16 @@ |
||||
//
|
||||
// AlphaWalletGoBack.h
|
||||
// AlphaWalletGoBack
|
||||
//
|
||||
|
||||
#import <Foundation/Foundation.h> |
||||
|
||||
//! Project version number for AlphaWalletGoBack.
|
||||
FOUNDATION_EXPORT double AlphaWalletGoBackVersionNumber; |
||||
|
||||
//! Project version string for AlphaWalletGoBack.
|
||||
FOUNDATION_EXPORT const unsigned char AlphaWalletGoBackVersionString[]; |
||||
|
||||
// In this header, you should import all the public headers of your framework using statements like #import <AlphaWalletGoBack/PublicHeader.h>
|
||||
|
||||
#import <AlphaWalletGoBack/GoBack.h> |
@ -0,0 +1,7 @@ |
||||
#import <UIKit/UIKit.h> |
||||
|
||||
@interface UIApplication(GoBack) |
||||
|
||||
- (BOOL)goBackToPreviousAppIfAvailable; |
||||
|
||||
@end |
@ -0,0 +1,24 @@ |
||||
@import UIKit; |
||||
@import ObjectiveC.runtime; |
||||
|
||||
@interface UISystemNavigationAction : NSObject |
||||
@property(nonatomic, readonly, nonnull) NSArray<NSNumber*>* destinations; |
||||
-(BOOL)sendResponseForDestination:(NSUInteger)destination; |
||||
@end |
||||
|
||||
@implementation UIApplication(GoBack) |
||||
|
||||
//Derived from https://stackoverflow.com/a/43102093 |
||||
- (BOOL)goBackToPreviousAppIfAvailable{ |
||||
Ivar sysNavIvar = class_getInstanceVariable(UIApplication.class, "_systemNavigationAction"); |
||||
UIApplication* app = UIApplication.sharedApplication; |
||||
UISystemNavigationAction* action = object_getIvar(app, sysNavIvar); |
||||
if (action) { |
||||
NSUInteger destination = action.destinations.firstObject.unsignedIntegerValue; |
||||
return [action sendResponseForDestination:destination]; |
||||
} else { |
||||
return NO; |
||||
} |
||||
} |
||||
|
||||
@end |
@ -0,0 +1,21 @@ |
||||
MIT License |
||||
|
||||
Copyright (c) 2022 AlphaWallet |
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy |
||||
of this software and associated documentation files (the "Software"), to deal |
||||
in the Software without restriction, including without limitation the rights |
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
||||
copies of the Software, and to permit persons to whom the Software is |
||||
furnished to do so, subject to the following conditions: |
||||
|
||||
The above copyright notice and this permission notice shall be included in all |
||||
copies or substantial portions of the Software. |
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
||||
SOFTWARE. |
Loading…
Reference in new issue