PostHog / posthog-ios

PostHog iOS SDK
https://posthog.com/docs/libraries/ios
MIT License
29 stars 37 forks source link

`handleActionWithIdentifier` throws if app is open from a notification - cold start #70

Closed marandaneto closed 9 months ago

marandaneto commented 9 months ago

iOS unrecognized selector sent to instance

cameronehrlich commented 9 months ago

https://github.com/PostHog/posthog-ios/assets/1508740/fea86c8c-7e55-4b6a-a3f8-87c2acc3f855

Screenshot 2023-10-02 at 10 27 17 AM
marandaneto commented 9 months ago

I can reproduce this locally as well, thanks for the video @cameronehrlich. The app does not need to be in the background nor be opened via a notification, just calling:

    NSMutableDictionary *payload = [[NSMutableDictionary alloc] init];
    [[PHGPostHog sharedPostHog] handleActionWithIdentifier:(@"identifier")
                                     forRemoteNotification:(payload)];

The reason is that the PHGPostHogIntegration method does not have the handleActionWithIdentifier signature and this method is called dynamically here then here.

This probably happens with 3 methods actually:

- (void)receivedRemoteNotification:(NSDictionary *)userInfo;
- (void)failedToRegisterForRemoteNotificationsWithError:(NSError *)error;
- (void)handleActionWithIdentifier:(NSString *)identifier forRemoteNotification:(NSDictionary *)userInfo;

If you call any of them, don't, an easy fix is to just add those methods (empty body) to PHGPayloadManager but I need to figure out what's supposed to be the implementation first, if any.

marandaneto commented 9 months ago

@benjackwhite do you have any context about that? what should those methods do?