pixeldock / rxappstate Goto Github PK
View Code? Open in Web Editor NEWRxSwift extensions for UIApplicationDelegate methods to observe changes in your app's state
License: MIT License
RxSwift extensions for UIApplicationDelegate methods to observe changes in your app's state
License: MIT License
The project was updated to use the Swift 5 version of RxSwift, but the Swift version was not incremented to allow Xcode 10.2 to build it (it needs at least 4.2).
Hi,
I have to open a resource specified by a URL.
The delegate "UIApplicationDelegate.application(_:open:options:)" is never call when I use your rx extension. (work fine otherwise)
So I tried to add it inside your extension like this :
public var applicationOpenURL: Observable<AppState> { return delegate.methodInvoked(#selector(UIApplicationDelegate.application(_:open:options:))) .map { _ in .active } }
but that seems doesn't work.
Hello,
I want to update information when user opens the app for the first time after a specific update, so I'm subscribing to firstLaunchOfNewVersionOnly as specified in the doc. But I never enter it even if I've changed the version number from 5.2 to 6.0. I'm using the version 1.1.0 of RxAppState.
Do you have any idea please ?
Good to have tvOS support
Hello,
I would like to have an Observable with the same behavior as isFirstLaunchOfNewVersion
, but which also emits true
on first app launch.
The appVersion
base observable is not enought to achieve this. This is because the AppVersion
struct does not help distinguishing between the very first launch and "regular" app launches.
The workaround I have so far is something like:
Observable.zip(isFirstLaunch,isFirstLaunchOfNewVersion) { $0 || $1 }
Do you have a better idea how one could achieve this?
Maybe AppVersion
could include some additional let isFirstLaunch: Bool
attribute? This way it would fully represent the app state.
RxSwift 5.0.0 support
...
I implemented UNUserNotificationCenterDelegate protocol in my AppDelegate,
then use UIApplication.shared.rx.appState.map...etc
Then after getting push from system RxApplicationDelegateProxy crashed with unrecognized selector at [RxAppState.RxApplicationDelegateProxy userNotificationCenter:didReceiveNotificationResponse:withCompletionHandler:]
After a bit of debugging it seems that forward delegate in RxCocoa's DelegateProxy is nil
Hello mates!, could You please update your Rx dependencies to 6.0 version
Currently the framework cannot be imported in an extension because of the presence of UIApplication.shared
in UIApplication.Rx.swift
extension RxAppState {
/**
For testing purposes
*/
internal static func clearSharedObservables() {
objc_setAssociatedObject(UIApplication.shared,
&_sharedRxAppStateKey,
nil,
.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
}
The problem would be resolved just by injecting the application
in the method
internal static func clearSharedObservables(application: UIApplication) {
objc_setAssociatedObject(application,
&_sharedRxAppStateKey,
nil,
.OBJC_ASSOCIATION_RETAIN_NONATOMIC)
}
I need to start each time a user app running some initialization work, is in "didFinishLaunchingWithOptions" runs some initialization work.
I found it wrong to use "isFirstLaunch" because it only works when the app is first installed, not every time it runs.
When using Carthage I get this error
MyProject/Classes/Models/Helpers/Helper.swift:11:8: Module file's minimum deployment target is ios10.3 v10.3: MyProject/Carthage/Build/iOS/RxAppState.framework/Modules/RxAppState.swiftmodule/x86_64.swiftmodule
Can you modify the deployment target for your module please ?
I am having an issue since I installed the RxAppState framework. I can no longer call this
if let appDele = UIApplication.shared.delegate as? AppDelegate {
}
This always fails now. If I try to force unwrap, it crashes with following error
Could not cast value of type 'RxAppState.RxApplicationDelegateProxy' (0x7f95fae20b20) to 'CustomApp.AppDelegate' (0x1099ec9e8).
Could anyone tell me a workaround to this issue?
I need to access my AppDelegate, but when I do this let appDelegate = UIApplication.shared.delegate as! AppDelegate
, an error occurs that I can't cast RxAppState.RxApplicationDelegateProxy
to AppDelegate
.
After update start catch subj error while build time.
Maybe we something missing?
p.s. ios14+
It was easy recreate this crash if you have objective-c app with code like this in app delegate
@implementation AppDelegate
+ (instancetype)sharedDelegate {
return (AppDelegate*)[UIApplication sharedApplication].delegate;
}
Now any calls sharedDelegate in objective-c will return RxApplicationDelegateProxy and crash when you try access to any property of AppDelegate.
2019-08-17 21:20:08.183948+0300 CS DEV[3789:29536] *** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '-[RxAppState.RxApplicationDelegateProxy managedObjectContext]: unrecognized selector sent to instance 0x600003ed3240'
Originally posted by @Tayphoon in #11 (comment)
Hello,
could it be possible to use latest RxSwift version in pod dependencies? This would not require any change in the code.
Thanks!
Hello,
thank again for this great Pod!
I think there is a potential issue if you do not subscribe to all RxAppState Observable.
In my case, I have been using RxAppState since the public release of my App.
But first we only used the didOpenApp
alike Observables, not the ones that involves UserDefaults such as isFirstLaunch
, isFirstLaunchOfNewVersion
, etc.
Therefore, if I start using isFirstLaunch
in a new version of the App, then they will all trigger something wrong since the UserDefaults memory were not filled in the previous App versions since I never subscribed to them.
So I wonder whether it would not be better if RxAppState internally listen to AppDelegate notification and update its UserDefault memory internally, even if no Observables are subscribed.
I would be happy to have your opinion on this.
RxSwift 4.0.0 support
At least since iOS 11 release last year, Apple recommends against using this - ever! They say: "this method is unnecessary and shouldn't be used" (https://developer.apple.com/documentation/foundation/userdefaults/1414005-synchronize)
Apple guarantees the synchronization will happen itself when needed. Using synchronize is bad because it's blocking and it writes to storage not just one change, but the whole dictionary which shouldn't be big, but can be. I still see a lot of guides on UserDefaults sort of advertising the synchronize and it's a pity. It became an anti-pattern.
In my opinion, this line should just be removed.
Hi, beginning with Mai 1st 2024 Apple requires that 3rd party SDK must habe a PrivacyInfo manifest included into there code.
https://developer.apple.com/support/third-party-SDK-requirements/
https://developer.apple.com/documentation/bundleresources/privacy_manifest_files
I've scanned my app with the following script (https://github.com/Wooder/ios_17_required_reason_api_scanner) for traces of code that requires action and your project was mentioned because if the usage of UserDefaults.
Can you please check it yourself and add a PrivacyInfo file?
Found potentially required reason API usage 'UserDefaults' in '...../Pods/RxAppState/Pod/Classes/UIApplication+Rx.swift'Line numbers: 91 305 319 325 336 Found potentially required reason API usage 'NSUserDefaults' in '...../Pods/RxAppState/Pod/Classes/UIApplication+Rx.swift' Line numbers: 91
When using firstLaunchOfNewVersionOnly
, I'd like to tell know the previous and current versions of the app.
The intent is to give a user a "What's new" type into if the version was prior to x.x.x
. If the previous version was later, the "What's new" flow will be skipped. This would help to determine if the user has previously been introduced to a new feature, and to avoid repeatedly introducing said feature.
If firstLaunchOfNewVersionOnly
was of type Observable<(String, String)>
, subscribers to next
events would receive the required information. This would be simpler than retrieving the Strings from UserDefaults
manually.
The name specified in Package.swift is RxSwiftExt, Xcode fails to resolve this package if RxSwiftExt also is present is added in dependencies.
Line 6 in 638a8aa
SPM Error is fixed in master
branch, but there is no tag for it (probably 1.6.1
)
Hello,
first of all, thank you very much for your very convenient code!
I have a question about the Observables related to version number, like isFirstLaunchOfNewVersion.
My question is: would it be safer to share these observables by default, using a .share() operator?
The point is: if I subscribe twice to an observable like isFirstLaunchOfNewVersion, its side-effect code on the UserDefaults will be run twice, so one of the subscription will not work as expected.
Thank you very much,
Philippe
Any interest in adding UISceneDelegate
support? It seems that when you adopt the UISceneDelegate
, some app lifecycle methods don't get called, instead the corresponding SceneDelegate methods are called. Example, sceneDidBecomeActive
instead of applicationDidBecomeActive
.
(this issue is quite similar to #18)
Hello,
thanks again for this Pod. I have started using its UIViewController
methods which are really great β in my opinion they definitely should be part of the RxSwift/RxCocoa "standard library".
I think that viewState
behavior might be surprising in the case it is not subscribed to at the very beginning of the UIViewController creation. Indeed, for instance, if is subscribed to after the base method viewDidAppear()
is invoked for the first, time, then viewState
will not emit .viewDidAppear
immediately, but will emit nothing until viewWillDisappear()
is invoked.
Maybe viewState
should behave like a state, not just like a combination of events: any time some observer subscribes to it, it should immediately get an event true
or false
.
To do so, there would be two things to do:
.share(replay: 1, scope: .forever)
and a .startWith(xx)
.viewDidAppear
, viewWillDisappear
and similar Observables, even if externally there are no subscribers to it. Maybe using a .publish()
and .connect()
to do this kind of "pre-fetch", or using an internal DisposeBag
property (maybe with something like NSObject-Rx?)Thank you very much, I would be pleased to know your opinion on this.
P.S. : And to go a bit further, it might be interesting to expose it as a Driver
instead of an Observable
.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. πππ
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google β€οΈ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.