-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[TIMOB-26294] TiAPI: Notify app about user-interactions #10248
Changes from 9 commits
1918832
e4daafd
b33b541
45c13b8
558c3d8
e75a0ce
b876597
34b4fb5
17dd252
e5e1bd8
60d9ca8
5644e96
8d5a56a
6dd6609
01e2cf2
1e0ea8f
bda342b
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#import <UIKit/UIKit.h> | ||
|
||
@interface TiUIApplication : UIApplication { | ||
} | ||
- (void)sendEvent:(UIEvent *)event; | ||
@end |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#import "TiUIApplication.h" | ||
|
||
@implementation TiUIApplication | ||
|
||
- (void)sendEvent:(UIEvent *)event | ||
{ | ||
[super sendEvent:event]; | ||
|
||
for (UITouch *touch in event.allTouches) { | ||
if (touch.phase == UITouchPhaseBegan) { | ||
[[NSNotificationCenter defaultCenter] postNotificationName:@"kTiUserInteraction" object:nil]; | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I am starting to become unsure if we should really have this in the core. I understand the purpose for you, but this was requested by maybe 5 devs over the last years, and it must have some kind of performance hit if we post an internal notification for every tap that is made in an app. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I do agree with your concerns about potential perfomance hit. On Android, the onUserInteraction will also loop over the event listeners in order to fire an event. It can have performance impact on both platforms, but while testing it, I wasn't able to "feel"/measure it. I also understand that on Android, we're firing an event for a native event (onUserInteraction). iOS doesn't have this event by default, so this workaround is mentioned as a solution for this problem (https://blog.gaelfoppolo.com/detecting-user-inactivity-in-ios-application-684b0eeeef5b) In order to improve performance, there should be an In a use case from our customer, we're in the need of implementing a way to automatically logout after x-seconds of non-activity. The way it's implemented now (firing events for user interctions) is the only way to catch user activity in Titanium, so we can handle further stuff in our Javascript code. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If we use a design that has a property (let's say There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks for your comment, but I don't have any knowledge about preprocessor macros. On Android, I think that the event is only fired when there is a listener registered. |
||
} | ||
} | ||
} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also lint here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Dont! |
||
|
||
@end |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This needs to be updated to 7.5.0 before merge now...