Skip to content
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

Not swizzling delegate functions correctly for UNUserNotificationCenter.current #122

Closed
andschdk opened this issue Aug 14, 2017 · 5 comments

Comments

@andschdk
Copy link

andschdk commented Aug 14, 2017

The log:

[Mixpanel - Swizzle.swift - func swizzleSelector(_:withSelector:for:name:block:)] (error) - Swizzling error: Cannot find method for userNotificationCenter:willPresentNotification:withCompletionHandler: on NotificationManager

Where NotificationManager is implementing UNUserNotificationCenterDelegate and setting:

UNUserNotificationCenter.current().delegate = self
@yarneo
Copy link
Contributor

yarneo commented Aug 15, 2017

hey @andschdk , i thought in your other issue you opened it was tracking for you (at least in foreground). Also let's please try to put everything in one issue as it seems to be related to the same thing

@yarneo
Copy link
Contributor

yarneo commented Aug 15, 2017

If it's not tracking for you then can you please give me some more info onto when NotificationManager is initialized and does that manager implement userNotificationCenter:willPresentNotification:withCompletionHandler:?

@andschdk
Copy link
Author

Hi @yarneo
Sorry for opening one more issue, I just think this is not related to each other. This is most likely a bug (or a setup issue on my end), while the other (#119) is a discussion about when and where to track push opens when using the new .

The order of initialisation is:

  1. NotificationManager (setting UNUserNotificationCenter.current().delegate = self)
  2. Mixpanel.initialize(...)

With the debugger attached it looks like there is no trouble resolving UNUserNotificationCenter.current().delegate as I can step to https://github.com/mixpanel/mixpanel-swift/blob/master/Mixpanel/AutomaticEvents.swift#L171

Is it on purpose that the aClass var is always pointing to the main application delegate?
https://github.com/mixpanel/mixpanel-swift/blob/master/Mixpanel/AutomaticEvents.swift#L168
Then it is always parsed as argument to the swizzler right? https://github.com/mixpanel/mixpanel-swift/blob/master/Mixpanel/AutomaticEvents.swift#L199

Have you tried it out yourself or am I on my own here 😕 ?

@yarneo
Copy link
Contributor

yarneo commented Aug 15, 2017

hey @andschdk the latest push to master should be able to resolve your issue, ill try to send out a release by end of week!

@yarneo yarneo closed this as completed Aug 15, 2017
@andschdk
Copy link
Author

Hi @yarneo , thanks for your latest commit.
I am still not able to use another class as UNUserNotificationCenterDelegate except for the main application.

It still fails with the swizzling here: https://github.com/mixpanel/mixpanel-swift/blob/master/Mixpanel/Swizzle.swift#L81

I made some updates in the demo project to illustrate the problem. On branch swizzle-bug-fix-ios10
https://github.com/andschdk/mixpanel-swift/tree/swizzle-bug-fix-ios10

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants