-
Notifications
You must be signed in to change notification settings - Fork 504
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
Remove PushKit #3268
Remove PushKit #3268
Conversation
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
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.
I have not finished the review yet. Will come back to it in 2h.
- (void)didReceiveRemoteNotification:(NSDictionary *)userInfo | ||
fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler | ||
{ | ||
// NSLog(@"[PushNotificationService][Push] didReceiveRemoteNotification: applicationState: %tu - payload: %@", [UIApplication sharedApplication].applicationState, userInfo); |
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.
Can we still log the call of this function?
It could be useful for sanity check.
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.
👍
RiotNSE/NotificationService.swift
Outdated
Bundle.mxk_customizeLocalizedStringTableName("Vector") | ||
|
||
if isatty(STDERR_FILENO) == 0 { | ||
// MXLogger.setSubLogName("nse") |
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.
To fix. Logs are useful
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.
👍
RiotNSE/NotificationService.swift
Outdated
} | ||
|
||
theUserAccount.mxSession.event(withEventId: theEventId, inRoom: theRoomId, success: { [weak self] (event) in | ||
guard let strongSelf = self else { |
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.
You can use the following swift 4.x:
guard let strongSelf = self else { | |
guard let self = self else { |
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.
👍
RiotNSE/NotificationService.swift
Outdated
return | ||
} | ||
|
||
guard let theEvent = event else { |
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.
guard let theEvent = event else { | |
guard let event = event else { |
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.
👍
RiotNSE/NotificationService.swift
Outdated
} | ||
|
||
func processEvent(_ event: MXEvent) { | ||
if let content = originalContent, let theUserAccount = userAccount { |
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.
You could use userAcccount = self.userAccount to unwrap the value.
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.
👍
RiotNSE/NotificationService.swift
Outdated
// Modify the notification content here... | ||
guard let newContent = notificationContent else { | ||
// remove | ||
UNUserNotificationCenter.current().removePendingNotificationRequests(withIdentifiers: [self.requestIdentifier!]) |
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.
We should always unwrap optionals for long term sanity.
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.
👍
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
{ | ||
NSLog(@"[PushNotificationService][Push] didReceiveRemoteNotification: applicationState: %tu - payload: %@", [UIApplication sharedApplication].applicationState, userInfo); | ||
// | ||
// // Display local notifications only when the app is running in background. |
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.
Could we remove commented code?
This is to avoid to keep dead comments for years. Specially when there is no "comment" for the commented section.
We will be able to retrieve this piece of code in git if we need it one day.
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.
👍
CALLS_ENABLE_CALLKIT_INDEX = 0, | ||
CALLS_CALLKIT_DESCRIPTION_INDEX, | ||
CALLS_ENABLE_STUN_SERVER_FALLBACK_INDEX, | ||
//CALLS_ENABLE_CALLKIT_INDEX = 0, |
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.
I think we can clear this commented piece of code as well.
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.
👍
RiotNSE/NotificationService.swift
Outdated
func fetchEvent() { | ||
guard let content = originalContent, let userAccount = self.userAccount else { | ||
// there is something wrong, do not change the content | ||
NSLog("[NotificationService] Fallback case 4") |
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.
Could we have more detail in the log for future debugging?
Like:
NSLog("[NotificationService] Fallback case 4") | |
NSLog("[NotificationService] fetchEvent: Fallback case 4. There is something wrong, do not change the content") |
This worths for all Fallback case X
:)
I do not understand the order for X :/
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.
You're totally right. It was easy for debugging on development. Changing them all.
} | ||
|
||
guard let event = event else { | ||
return |
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.
Should we call self.fallbackToOriginalContent()
here?
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.
Yes, it will be more clear.
RiotNSE/NotificationService.swift
Outdated
} | ||
|
||
// should show decrypted content in notification | ||
guard event.clear == nil else { |
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.
guard event.clear == nil else { | |
if event.clear { |
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.
Updated
RiotNSE/NotificationService.swift
Outdated
} | ||
|
||
func launchBackgroundSync() { | ||
guard let userAccount = userAccount else { return } |
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.
Should we call self.fallbackToOriginalContent() here?
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.
Also adding this
Co-authored-by: manuroe <[email protected]>
Co-authored-by: manuroe <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Co-authored-by: manuroe <[email protected]>
Co-authored-by: manuroe <[email protected]>
Co-authored-by: manuroe <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
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.
Using a new implementation NSEMemoryStore is really smart 👍
RiotNSE/NotificationService.swift
Outdated
store = MXFileStore(credentials: userAccount.mxCredentials) | ||
if let userAccount = MXKAccountManager.shared()?.activeAccounts.first { | ||
store = NSEMemoryStore(withCredentials: userAccount.mxCredentials) | ||
store.open(with: userAccount.mxCredentials, onComplete: nil, failure: nil) |
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.
It can be removed. It is called by MXSession.setStore()
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.
That's right. Removing.
RiotNSE/NotificationService.swift
Outdated
room.state({ (roomState: MXRoomState!) in | ||
|
||
// initialize a temporary file store, just to load the room state | ||
let fileStore = MXFileStore(credentials: session.credentials) |
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.
Why not using the existing NSEMemoryStore
and implement stateOfRoom
there?
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.
Yes, totally makes sense. Updating.
Signed-off-by: ismailgulek <[email protected]>
Signed-off-by: ismailgulek <[email protected]>
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.
All good for me!
Signed-off-by: ismailgulek <[email protected]>
Fix #2714