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

Daily notification to ask users to label their trips #703

Closed
lgharib opened this issue Feb 14, 2022 · 19 comments
Closed

Daily notification to ask users to label their trips #703

lgharib opened this issue Feb 14, 2022 · 19 comments

Comments

@lgharib
Copy link

lgharib commented Feb 14, 2022

Where is the daily scheduled mechanism notification system to invite users to label there trips located?

@PatGendre
Copy link
Contributor

Hi @lgharib : the code is not in the main e-mission-phone app,
I'd say it is in this plugin (to be confirmed)
https://github.com/e-mission/e-mission-transition-notify

@shankari
Copy link
Contributor

shankari commented Feb 14, 2022

@PatGendre that code is for trip-end notifications. Our testers found the trip-end notifications too bothersome.

@lgharib
we generate a notification at the end of the day by adding the following line to the crontab (where we have also configured the analysis pipeline etc).

0 3 * * * ./e-mission-py.bash bin/push/push_to_users.py -t "Trip labels requested" "Please label your trips for the day" -a  >> /var/log/push_trip_reminder.stdinout 2>&1

@shankari
Copy link
Contributor

Once you confirm that this works, would be great if you could update the instructions.
If you want to include the label assist feature, you would also need

0 10 * * * ./e-mission-py.bash bin/build_label_model.py -a >> /var/log/better_model.log 2>&1

@PatGendre
Copy link
Contributor

@shankari thanks for the explanation :-)
I'll see with the la Rochelle team if we add this daily cron, as currently we don't ask the users to label all their trips.
As for the second cron, it is the last pipeline step which infersand completes the uncompleted labels from the already completed ones via ML, correct ?

@shankari
Copy link
Contributor

shankari commented Feb 16, 2022

@PatGendre the second cron actually builds the tour model for the users from the already completed trips. The step that infers and completes the uncompleted labels is run as part of the intake pipeline.
https://github.com/e-mission/e-mission-server/blob/master/emission/pipeline/intake_stage.py#L166

@PatGendre
Copy link
Contributor

@shankari thanks for the explanation.
If I understand well, the tour model is completely independent from the inference model used to label trips?
Its goal is to create a weekly list of most frequent trips every day, correct?
So the second cron is only useful if we'd want to analyse the predicted frequent trips, and the results of the model are not visible to the end-users anyway, at least via the app.

@shankari
Copy link
Contributor

shankari commented Feb 25, 2022

@PatGendre each trip now has two inferences:

  • from sensor data (shown at the top right of the diary card)
  • from prior labeled data (shown as yellow labels)

We use the tour model to generate the second.
So the tour model results are visible to end-users.

@shankari
Copy link
Contributor

Closing this since the original question has been answered

@lgharib
Copy link
Author

lgharib commented Mar 23, 2022

@PatGendre that code is for trip-end notifications. Our testers found the trip-end notifications too bothersome.

@lgharib we generate a notification at the end of the day by adding the following line to the crontab (where we have also configured the analysis pipeline etc).

0 3 * * * ./e-mission-py.bash bin/push/push_to_users.py -t "Trip labels requested" "Please label your trips for the day" -a  >> /var/log/push_trip_reminder.stdinout 2>&1

Hi @shankari I am trying to implement push notification with Ma Mobilité using Firbase.

We replaced the google-service.js and GoogleService-Info.plist by the one we created on Firebase. I did a build and published it to test on my Samsung Galaxy S10.

From the Firebase console I tried to send a message to both Apps but didn't receive any notification.

On another hand I wanted to send a message to specific device from the console test tool but I couldn't find the FCM device token in the profiles in the e-mission server database.

Apparently the device_tokens are supposed to be pushed to the server from the phone on splash screen intialisation.

I noticed that the PushNotify.startupInit(); was commented (so is the 'emission.splash.pushnotify' module reference) in www/js/controllers.js. I decided to remove the comment on it but I received the following message:
image

After investigating the master branch of e-mission-phone I noticed that you no longer use "phonegap-plugin-push": "=2.3.0" so I replaced it with "@havesource/cordova-plugin-push": "2.0.0". But after building again I still have the issue

image

@shankari
Copy link
Contributor

@lgharib when did you last pull from the e-mission-phone master? I changed to havesource 5 months ago (e-mission/e-mission-phone@6ebeb28), and merged that change into master in December (e-mission/e-mission-phone#804). I made a bunch of other upgrades at the same time, so I would suggest:

  • starting from the current master and getting it to work and then
  • either porting your UI changes to master or backporting from master to your fork

Couple of other things to check:

$ find platforms/android -name \*google-services\*
platforms/android/app/google-services.json
platforms/android/app/build/generated/res/google-services
  • The errors above are still using phonegap-plugin-push (see the backtrace). Are you sure you replaced the plugin correctly?

@shankari
Copy link
Contributor

I noticed that the PushNotify.startupInit(); was commented (so is the 'emission.splash.pushnotify' module reference) in www/js/controllers.js. I decided to remove the comment on it but I received the following message:

That is because, in order to make the modules self-contained, the push notifications are now initialized from within the module.
https://github.com/e-mission/e-mission-phone/blob/42706f3f40423f91d02db443e011f45b8385505d/www/js/splash/pushnotify.js#L156

In the $ionicPlatform.ready(). callback, if and only if the user has consented, we call pushnotify.registerPush() -> pushnotify.registerPromise() -> pushnotify.startupInit();

@shankari
Copy link
Contributor

shankari commented Apr 1, 2022

@lgharib were you able to figure this out?

@shankari shankari reopened this Apr 1, 2022
@lgharib
Copy link
Author

lgharib commented Apr 7, 2022

@lgharib when did you last pull from the e-mission-phone master? I changed to havesource 5 months ago (e-mission/e-mission-phone@6ebeb28), and merged that change into master in December (e-mission/e-mission-phone#804). I made a bunch of other upgrades at the same time, so I would suggest:

* starting from the current master and getting it to work and then

* either porting your UI changes to master or backporting from master to your fork

Couple of other things to check:

* are you copying over your google configuration _after_ finishing setup and activate? Otherwise, they will get overwritten by the fake values (https://github.com/e-mission/e-mission-phone/blob/master/setup/setup_shared_native.sh#L7)

* are your configurations being copied correctly into `platform/android` and `platform/ios`? e.g. do these files have the correct values?
$ find platforms/android -name \*google-services\*
platforms/android/app/google-services.json
platforms/android/app/build/generated/res/google-services
* The errors above are still using `phonegap-plugin-push` (see the backtrace). Are you sure you replaced the plugin correctly?

HI @shankari thank you for your answer. I am still troubleshooting. I have pulled the latest version of master. Also I noticed the overwrite with the fake configutaion so I commented the script in https://github.com/e-mission/e-mission-phone/blob/master/setup/setup_shared_native.sh#L7 to make sur that the configuration in platform/android and platform/ios is correct. I think my issue is more with phonegap-plugin-push and not being replaced correctly.

@shankari
Copy link
Contributor

shankari commented Apr 8, 2022

@lgharib did you remove the plugin and re-add it? Just changing it in the config.xml doesn't do anything on cordova. doesn't even do it for cordova prepare - it will just use the cached value. You need to remove and re-add.

@lgharib
Copy link
Author

lgharib commented Apr 8, 2022

@shankari thank you for your advice it was probably related to the cache. I was able to build a version that sends the device_token correctly to the server.

I have now two device_tokens and tested sending push notifications using the script and Firebase online console but still not notifications on my phone.

./e-mission-py.bash bin/push/push_to_users.py -t "Trip labels requested" "Please label your trips for the day" -a

WARNING:root:ignoring entry {'curr_platform': 'android'} due to None values
WARNING:root:ignoring entry {'curr_platform': 'android'} due to None values
WARNING:root:ignoring entry {'curr_platform': 'android'} due to None values
DEBUG:root:adding token dZ7AqZzMIgQ:APA91bENtszZtewKzDzFRR2W9fV4JEFypM643-h1aLutH7NzprJJ9ZbBXhxBp5eBMSau65TA6jV6dgE0Y249H2RwCjeYYTUGxmUntSUQ8xLwCO7R_F4n_JI62rSodvI_1iHtGiBmUF0n to list for platform android
DEBUG:root:adding token cKAAUyOUpi0:APA91bG4FZjEE_VdmV5iGPsNPmNn6Zj6ghSwSRldXcno7XYl1OotV_xBP2IIOR-7SFjgufnZfn13Sz0mRQiWjRFYc8YN5R3ohQok8C7cIJuh-tv5hZTbgse8csT4JttlBPsgk9quRuRv to list for platform android
DEBUG:root:user_id_list of length 197 -> token list of length 3
DEBUG:root:module_name = emission.net.ext_service.push.notify_interface_impl.firebase
DEBUG:root:module = <module 'emission.net.ext_service.push.notify_interface_impl.firebase' from '/root/e-mission-server/emission/net/ext_service/push/notify_interface_impl/firebase.py'>
DEBUG:root:interface_obj_fn = <function get_interface at 0x7fc2c6127560>
DEBUG:root:interface_obj = <emission.net.ext_service.push.notify_interface_impl.firebase.FirebasePush object at 0x7fc2c614c410>
DEBUG:root:interface_obj = <emission.net.ext_service.push.notify_interface_impl.firebase.FirebasePush object at 0x7fc2c614c410>
DEBUG:root:len(token_list) == 0, skipping fcm token mapping to save API call
after mapping iOS tokens, imported 0 -> processed 0
combo token map has 0 ios entries and 3 android entries
DEBUG:urllib3.util.retry:Converted retries value: 3 -> Retry(total=3, connect=None, read=None, redirect=None, status=None)
DEBUG:urllib3.connectionpool:Starting new HTTPS connection (1): fcm.googleapis.com:443
DEBUG:urllib3.connectionpool:https://fcm.googleapis.com:443 "POST /fcm/send HTTP/1.1" 200 None
DEBUG:root:{'ios': {'multicast_ids': [], 'success': 0, 'failure': 0, 'canonical_ids': 0, 'results': [], 'topic_message_id': None}, 'android': {'multicast_ids': [4376886211604052196], 'success': 2, 'failure': 1, 'canonical_ids': 0, 'results': [{'error': 'NotRegistered'}, {'message_id': '0:1649443137437889%8a377dcbf9fd7ecd'}, {'message_id': '0:1649443137441087%8a377dcbf9fd7ecd'}], 'topic_message_id': None}}
DEBUG:root:module_name = emission.net.ext_service.push.notify_interface_impl.firebase
DEBUG:root:module = <module 'emission.net.ext_service.push.notify_interface_impl.firebase' from '/root/e-mission-server/emission/net/ext_service/push/notify_interface_impl/firebase.py'>
DEBUG:root:interface_obj_fn = <function get_interface at 0x7fc2c6127560>
DEBUG:root:interface_obj = <emission.net.ext_service.push.notify_interface_impl.firebase.FirebasePush object at 0x7fc2c64ff610>
DEBUG:root:interface_obj = <emission.net.ext_service.push.notify_interface_impl.firebase.FirebasePush object at 0x7fc2c64ff610>
DEBUG:root:firebase push result for ios: success 0 failure 0 results []
DEBUG:root:firebase push result for android: success 2 failure 1 results [{'error': 'NotRegistered'}, {'message_id': '0:1649443137437889%8a377dcbf9fd7ecd'}, {'message_id': '0:1649443137441087%8a377dcbf9fd7ecd'}]

@shankari
Copy link
Contributor

shankari commented Apr 8, 2022

What do the phone logs show? Hard to debug without any logs.

Make sure that your phone screen is locked and the app is not opened - if it is opened, the notification is received directly by the app instead of showing up on the screen.

@lgharib
Copy link
Author

lgharib commented Apr 8, 2022

My bad! It needed time it worked

Thank you again for your help!

rn_image_picker_lib_temp_9a523d48-5e9f-4f69-9cc6-5d6cf4139110

@lgharib
Copy link
Author

lgharib commented Apr 8, 2022

What do the phone logs show? Hard to debug without any logs.

Make sure that your phone screen is locked and the app is not opened - if it is opened, the notification is received directly by the app instead of showing up on the screen.

Ok I think that's why the app was opened

@shankari
Copy link
Contributor

shankari commented Apr 8, 2022

Closing this issue since it appears to be resolved.

@shankari shankari closed this as completed Apr 8, 2022
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

3 participants