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

How do extensions work? #339

Open
IsaiahJTurner opened this issue Apr 2, 2021 · 9 comments
Open

How do extensions work? #339

IsaiahJTurner opened this issue Apr 2, 2021 · 9 comments
Assignees
Labels
question Further information is requested

Comments

@IsaiahJTurner
Copy link

Summary

I see platformDataDirectory resolves to the library directory however this is not shared between extensions/the core app. Is it possible to specify an app groups path for the data directory? Otherwise, how do I ensure events sync between the main app and the extension. Will events from the extension when network was unavailable still be uploaded by the main app?

@IsaiahJTurner IsaiahJTurner added the question Further information is requested label Apr 2, 2021
@haoliu-amp
Copy link
Contributor

Good question, are you trying to use our SDK for both app and extension?

@IsaiahJTurner
Copy link
Author

@haoliu-amp yes, we use a notification content extension (which has interactions) as well as a share extension (which has interactions) and we'd like to track them the same way we track those views in our core app

@IsaiahJTurner
Copy link
Author

For our Realm data store (the data caching layer of our app) we use an app groups data directory so that when tagging users in the share extension the local cache of contacts can be searched and for our session key we store it within the App Group's UserDefaults. I would presume a similar pattern is needed for Amplitude assuming the identify data is stored in some sore of local file/info.plist. We'd need to specify which storage location to use such that it will be shared across Extensions.

@IsaiahJTurner
Copy link
Author

In our initial testing, we are not seeing any events from the Extensions. Is there something we are doing incorrectly @haoliu-amp ?

@haoliu-amp
Copy link
Contributor

@IsaiahJTurner We will take a look. @jooohhn will be helping you soon.

@jooohhn
Copy link
Contributor

jooohhn commented Apr 8, 2021

@IsaiahJTurner thanks for your patience, I'm looking to get an answer to you by tomorrow

@jooohhn
Copy link
Contributor

jooohhn commented Apr 12, 2021

@IsaiahJTurner Could you clarify how you're setting up Amplitude in your extensions? Amplitude's dev docs mention some differences when using Amplitude in extensions. Events might not be uploaded if eventUploadPeriodSeconds exceeds how long the extension is open.

@sroebert
Copy link

I'm also running into issues when trying to use Amplitude with a notification service extension. It seems that the extension is killed right after processing notifications, so Amplitude is not able to perform the upload request.

Even manually forcing the events to be uploaded using Amplitude.instance().uploadEvents() will not work, as I need to know when the uploading has been completed.

Would it be possible to add a completion handler or an event when uploading has finished, allowing to wait for that event before completing the processing of the notification in the extension?

@kolboch
Copy link

kolboch commented Sep 8, 2022

What we've observed that events from notification extensions are reported the next time service was triggered. My only concern is: will they ever be reported without sending another notification (let's assume we send one and only notification, service reports to Amplitude event "Notification received", but it didn't manage to upload that to Amplitude, we never ever send one more notification, so notification service won't be triggered again, will such event get a chance to be uploaded?).
[edit] Ok, based on my ios service extension knowledge and available documentation it seems in the case described above such event will never be delivered. So for now my only idea to improve handling events reporting in notification service would be to extend time of processing before calling executeHandler() in notification service extension... which is quite counterintuitive, and as already mentioned in some of the previous answers would be best to have some way to know when amplitude is done with uploading after calling Amplitude.instance().uploadEvents()

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

No branches or pull requests

5 participants