tetujin / aware-client-ios-v2

AWARE Client iOS (Version2)
http://www.awareframework.com
22 stars 10 forks source link

ESM scheduling #1

Closed rkdarst closed 5 years ago

rkdarst commented 5 years ago

Hi,

I have been trying to schedule ESMs on Aware IOS v2 (or v1 for that matter, but I'm focusing on v2 now). I've been searching myself, and I guess it's about time to ask now...

Currently, I schedule ESM using the Aware Android scheduler. When the scheduler triggers, it queues the ESMs and sends them. I only use scheduled ESMs, no realtime ones (no MQTT, I did use it once but now don't anymore). In the aware study data returned by the server, there is a schedulers: [...] object with the scheduler definition. Inside the scheduler definition is the scheduler action, which contains the ESM definitions. When you think about it, this is probably somewhat android-specific.

In Aware iOS, I see a configuration option plugin_ios_esm_config_url which seems like it might be relevant, but can't be sure that it's in the same format - or how scheduling works with it.

I'm basically trying to understand the underlying API, since I am reimplementing it myself. If there is an example I can copy, that is good enough.

Do you have any hints for scheduled iOS ESMs?

tetujin commented 5 years ago

Hi @rkdarst ,

In aware-client-v2, internally the notification triggers are managed by iOS default local-push notification (UserNotifications) function. When the app download the ESM configuration (JSON format) (or setup ESM manually by source code), the app stores the configuration into local-storage, and schedules notification by using UserNotifications at the same time. The app checks that valid survey exists or not every time when the user opens the app. If there is a valid one, the app shows the survey on screen.

aware-client-v2 is just a UI. The main sensing and scheduling logic of aware-client-v2 is AWAREFramework-iOS (which is a library version of AWARE-iOS). aware-client-v2 is using the library ( https://github.com/tetujin/AWAREFramework-iOS ) as a backend. ESM is handled by ESMScheduleManager in the library. The class provides APIs for scheduling ESMs which allows us to reduce setup load of UniverNotifications and ESM configuration.

The sample code is here. You can install the library via CocoaPods. Moreover, you can set up a scheduled ESM like Android version of AWARE on your app. The sample code is written by Swift but you can also use Objective-C if you want. https://github.com/tetujin/AWAREFramework-iOS/tree/master/Example

I think AWARE-ConfigURLESM, AWARE-ScheduleESM, and DynamicESM will help your understanding.

Best, Yuuki

tetujin commented 5 years ago

Hi @rkdarst

Is the information above sufficient for you? If so, I would like to close this issue.

Best, Yuuki