Skip to content
This repository has been archived by the owner on Sep 4, 2020. It is now read-only.

notification_applicationDidBecomeActive method #447

Closed
code-smith opened this issue Dec 19, 2015 · 4 comments
Closed

notification_applicationDidBecomeActive method #447

code-smith opened this issue Dec 19, 2015 · 4 comments
Labels

Comments

@code-smith
Copy link

In AppDelegate+notification class the method notification_applicationDidBecomeActive replaces applicationDidBecomeActive but its not getting called when app becomes active.

Earlier i used applicationDidBecomeActive to reset badges when opened directly from clicking the app icon, and had few other actions but it doesnt look like i can do that here?
is this a bug or by design , Can anyone please help me here?

Thanks,
Sid

@macdonst
Copy link
Member

I'm going to revert the code that caused this problem. Hold tight.

@code-smith
Copy link
Author

Thanks..

macdonst added a commit that referenced this issue Dec 21, 2015
Reverts PR #426: Fix method swizzling on ios

Will revisit swizzling with changes necessary for cocoapods support
@macdonst
Copy link
Member

@code-smith published 1.5.2 to NPM. It should show up shortly. In the meantime you can install from the giturl.

devgeeks added a commit that referenced this issue Mar 1, 2016
This still isn't the "right way" linked in #427, but seems to be safe
and void of side effects due to the namespacing of all the methods.

It has been tested to work side by side with another plugin that also
swizzles AppDelegate's applicationDidBecomeActive.

1. wrapped swizzling in dispatch_once
2. first attempts class_addMethod / class_replaceMethod but if that
fails falls back to method_exchangeImplementations.
3. swizzled_init => pushPluginSwizzledInit (if other plugins attempt to
swizzle init and use the same name, there seems to be a collision)
4. added an observer for UIApplicationDidBecomeActiveNotification
instead of overriding applicationDidBecomeActive
5. applicationDidBecomeActive => pushPluginOnApplicationDidBecomeActive
(and it becomes a notification observer instead)

See http://nshipster.com/method-swizzling/ and "Avoid collisions" under
"Considerations".

This will need testng by someone that understands the plugin better than
I do, but it should not be changing the core functionality at all. The
pushPluginOnApplicationDidBecomeActive method *is* called when the
application becomes active, etc.

Goes a long way toward fixing #427 without regressing #447, etc.
macdonst pushed a commit that referenced this issue Mar 9, 2016
This still isn't the "right way" linked in #427, but seems to be safe
and void of side effects due to the namespacing of all the methods.

It has been tested to work side by side with another plugin that also
swizzles AppDelegate's applicationDidBecomeActive.

1. wrapped swizzling in dispatch_once
2. first attempts class_addMethod / class_replaceMethod but if that
fails falls back to method_exchangeImplementations.
3. swizzled_init => pushPluginSwizzledInit (if other plugins attempt to
swizzle init and use the same name, there seems to be a collision)
4. added an observer for UIApplicationDidBecomeActiveNotification
instead of overriding applicationDidBecomeActive
5. applicationDidBecomeActive => pushPluginOnApplicationDidBecomeActive
(and it becomes a notification observer instead)

See http://nshipster.com/method-swizzling/ and "Avoid collisions" under
"Considerations".

This will need testng by someone that understands the plugin better than
I do, but it should not be changing the core functionality at all. The
pushPluginOnApplicationDidBecomeActive method *is* called when the
application becomes active, etc.

Goes a long way toward fixing #427 without regressing #447, etc.
@lock
Copy link

lock bot commented Jun 5, 2018

This thread has been automatically locked.

@lock lock bot locked as resolved and limited conversation to collaborators Jun 5, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Development

No branches or pull requests

2 participants