Skip to content
This repository has been archived by the owner on Oct 15, 2024. It is now read-only.

Message Notification #78

Closed
ghost opened this issue Nov 29, 2015 · 51 comments
Closed

Message Notification #78

ghost opened this issue Nov 29, 2015 · 51 comments

Comments

@ghost
Copy link

ghost commented Nov 29, 2015

I know you use RSS for notifications for Facebook, however is there any way to add notifications for messages too? That way I can remove Facebook Messenger.

@indywidualny
Copy link
Owner

No way. I just don't know how to do it. Facebook Mobile website has no message notifications in its notification feed. I'm using a feed because it's reliable and simple.

But my app is open-source. If someone could help me it would be easier to make this feature.

@AlexMili
Copy link

AlexMili commented Dec 6, 2015

Maybe it would be possible to scrap messages URL to get all data needed.
I haven't any time to develop it but if someone could try it would be great !

@mcastillof
Copy link

I was thinking about message notifications. Please, take a look at this C++ project https://github.com/MartinBriza/gFB (I had to install QT-Creator to compile it). That program shows you when your contacts are online and offline and messages received, among other things. We can translate it from C++ to Java, and drop the things not needed. We just need to parse the messages received and show a notification. When the user press the notification it will display FaceSlim, so the user can chat from there.

@creativetrendsapps
Copy link
Contributor

I can help with this 👍

@ghost
Copy link
Author

ghost commented Jan 1, 2016

Awesome news!
On 1 Jan 2016 10:26 am, "Jorell Rutledge" [email protected] wrote:

I can help with this [image: 👍]


Reply to this email directly or view it on GitHub
#78 (comment)
.

@creativetrendsapps
Copy link
Contributor

Message notifications will work with this,

https://gist.github.com/creativetrendsapps/39ee0a94a0409b4fd21f :).

@indywidualny
Copy link
Owner

Awesome news! I will add this soon (next week).

sob., 2.01.2016, 08:20 Jorell Rutledge użytkownik [email protected]
napisał:

Message notifications will work with this,

https://gist.github.com/creativetrendsapps/39ee0a94a0409b4fd21f :).


Reply to this email directly or view it on GitHub
#78 (comment)
.

@creativetrendsapps
Copy link
Contributor

You can also do the same with notifications to avoid having the user getting redirected to get their RSS feed. The method used in Folio for Facebook, still grabs their RSS feed. It's based on the cookie manager though and an element from the Facebook SDK. I can share that with you as well if you'd like.

@indywidualny
Copy link
Owner

If you could publish a code snippet it would be great. I'm just curious. I
don't want to break anything. But getting notifications directly from a
Facebook notification feed seems the most reliable. I don't think I'm
changing it :)

sob., 2.01.2016, 15:05 Jorell Rutledge użytkownik [email protected]
napisał:

You can also do the same with notifications to avoid have the user getting
redirected to get their RSS feed. I can share that with you as well if
you'd like.


Reply to this email directly or view it on GitHub
#78 (comment)
.

@creativetrendsapps
Copy link
Contributor

https://gist.github.com/creativetrendsapps/0e6303daf9dc95978b35

With this you are still getting the notifications directly from a Facebook notification. The user just doesn't need to be redirected to get their RSS feed URL. If you would like to see a working example download Folio for Facebook from the Play Store. This is how I'm getting notifications.

@indywidualny
Copy link
Owner

Well. Thanks a lot :) I'm changing it. Awesome job, dude. I'm gonna add you
to app authors :D

sob., 2.01.2016, 16:24 Jorell Rutledge użytkownik [email protected]
napisał:

https://gist.github.com/creativetrendsapps/0e6303daf9dc95978b35

With this you are still getting the notifications directly from a Facebook
notification. The user just doesn't need to be redirected to get their RSS
feed URL. If you would like to see a working example download Folio for
Facebook from the Play Store. This is how I'm getting notifications.


Reply to this email directly or view it on GitHub
#78 (comment)
.

@creativetrendsapps
Copy link
Contributor

You're welcome :-). You're app has helped me so, it's the least I can do :-).

@indywidualny
Copy link
Owner

The only thing I'm missing is com.facebook.internal.ShareConstants class.
It's needed to create a feed pattern to add to base Facebook url.

Could you publish it somewhere?

@creativetrendsapps
Copy link
Contributor

Sure. Give me a sec.

@creativetrendsapps
Copy link
Contributor

@indywidualny
Copy link
Owner

Thanks. It seems to be just one constant with the value "href" so the class is not really needed. Ok, let's find out whether it is working. Everything is modified now to use your solution.

@creativetrendsapps
Copy link
Contributor

Lets see :-).

@indywidualny
Copy link
Owner

4ec51ca

Finally. It needs a lot of testing but should be good.
Should I put your name into App Info or just a nickname is ok? :)

Or just pull request and write whatever you want. Thanks a lot again!

@creativetrendsapps
Copy link
Contributor

Just put Creative Trends :-). I'm happy I could help!

@indywidualny
Copy link
Owner

Awesome. Just a quick update - notifications work! I'm not sure about message notifications, too late to write to someone but it probably works too :D

@creativetrendsapps
Copy link
Contributor

That's great! Again, I'm happy I could help. You've made a really great app!

@AlexMili
Copy link

AlexMili commented Jan 3, 2016

Great news ! @creativetrendsapps you rock !

@creativetrendsapps
Copy link
Contributor

👍

@pejakm
Copy link
Contributor

pejakm commented Jan 4, 2016

I've compiled latest code, notifications don't work at all.

@indywidualny
Copy link
Owner

Yes. There is a problem with mobile data. I'm guessing user agent is not
set.

It uses too much data too. I'm going to restore the previous "get feed"
button but make it semi-automatic now. It seems to be the best idea.

Data efficient, semi-automatic is better than the current solution. I need
more time to do this so next release is delayed.

pon., 4.01.2016, 16:31 Mladen Pejaković użytkownik [email protected]
napisał:

I've compiled latest code, notifications don't work at all.


Reply to this email directly or view it on GitHub
#78 (comment)
.

indywidualny pushed a commit that referenced this issue Jan 5, 2016
@indywidualny
Copy link
Owner

It's working now! Please test it if you want :)

I'm not sure about data usage. It may be higher. It's higher for sure. I'm not sure by how much yet.
If data usage is too high I can add a preference button to auto-generate the feed before activation of notifications. It's not so convenient though.

EDIT

Oh. I've already said this before. I'm repeating myself. I need more sleep ;)

I will leave notifications activated for the whole night and I will do some math in the morning. I hope a weekly data usage for 15 minute interval will be acceptable. We can discuss it later. I don't really care how much data I'm using but this app have to be "Slim".

indywidualny pushed a commit that referenced this issue Jan 7, 2016
@ghost
Copy link
Author

ghost commented Jan 7, 2016

I compiled the app yesterday, and get notifications for both messages and
normal.
On 7 Jan 2016 7:08 am, "Krzysztof Grabowski" [email protected]
wrote:

Well. I don't know why but there are no my logs. Just system logs :D


Reply to this email directly or view it on GitHub
#78 (comment)
.

@indywidualny
Copy link
Owner

@pejakm thanks for the crash report. Sorry about crash :)
Now I know everything. It's close to be finally resolved.

@pejakm
Copy link
Contributor

pejakm commented Jan 7, 2016

Still no Facebook notifications, sorry. :(

@indywidualny
Copy link
Owner

@pejakm don't worry. I will add a log saver soon to finally locate your issue.

@indywidualny
Copy link
Owner

Please test notifications with file logging enabled. Logs are saved to [sdcard]/FaceSlim.log
Please attach the file here (somehow). Maybe it will tell us more about notifications problems.

https://github.com/indywidualny/FaceSlim/blob/79066166bdea2844d2bd57b020325c547d28c0f5/app/app-release.apk

@pejakm
Copy link
Contributor

pejakm commented Jan 10, 2016

2016-01-10 09:38:47.762 NotificationsService: Time interval: 900 seconds
2016-01-10 09:38:47.842 NotificationsService: Internet connection active. Starting AsyncTasks...
2016-01-10 09:38:47.879 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-10 09:38:47.924 CheckMessagesTask: doInBackground: Processing... Trial: 1
2016-01-10 09:38:47.941 CheckMsgTask:getNumber: Trying: https://m.facebook.com/messages
2016-01-10 09:38:49.376 CheckMessagesTask: onPostExecute: Aight biatch ;)
2016-01-10 09:38:50.037 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-10 09:38:50.738 RssReaderTask: doInBackground: Processing... Trial: 1
2016-01-10 09:38:50.751 RssReaderTask: doInBackground: URL error
2016-01-10 09:38:50.763 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-10 09:38:51.811 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-10 09:38:52.084 RssReaderTask: doInBackground: Processing... Trial: 2
2016-01-10 09:38:52.125 RssReaderTask: doInBackground: URL error
2016-01-10 09:38:52.257 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-10 09:38:53.470 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-10 09:38:53.687 RssReaderTask: doInBackground: Processing... Trial: 3
2016-01-10 09:38:53.718 RssReaderTask: doInBackground: URL error
2016-01-10 09:38:53.764 RssReaderTask: onPostExecute: Failure
2016-01-10 09:53:48.009 NotificationsService: Time interval: 900 seconds
2016-01-10 09:53:48.056 NotificationsService: Internet connection active. Starting AsyncTasks...
2016-01-10 09:53:48.080 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-10 09:53:48.138 CheckMessagesTask: doInBackground: Processing... Trial: 1
2016-01-10 09:53:48.167 CheckMsgTask:getNumber: Trying: https://m.facebook.com/messages
2016-01-10 09:53:49.530 CheckMessagesTask: onPostExecute: Aight biatch ;)
2016-01-10 09:53:51.930 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-10 09:53:52.843 RssReaderTask: doInBackground: Processing... Trial: 1
2016-01-10 09:53:52.862 RssReaderTask: doInBackground: URL error
2016-01-10 09:53:52.882 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-10 09:53:53.716 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-10 09:53:53.987 RssReaderTask: doInBackground: Processing... Trial: 2
2016-01-10 09:53:54.005 RssReaderTask: doInBackground: URL error
2016-01-10 09:53:54.014 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-10 09:53:54.678 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-10 09:53:54.822 RssReaderTask: doInBackground: Processing... Trial: 3
2016-01-10 09:53:54.830 RssReaderTask: doInBackground: URL error
2016-01-10 09:53:54.850 RssReaderTask: onPostExecute: Failure
2016-01-10 10:08:48.259 NotificationsService: Time interval: 900 seconds
2016-01-10 10:08:48.349 NotificationsService: Internet connection active. Starting AsyncTasks...
2016-01-10 10:08:48.389 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-10 10:08:48.404 CheckMessagesTask: doInBackground: Processing... Trial: 1
2016-01-10 10:08:48.424 CheckMsgTask:getNumber: Trying: https://m.facebook.com/messages
2016-01-10 10:08:49.511 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-10 10:08:49.517 CheckMessagesTask: onPostExecute: Aight biatch ;)
2016-01-10 10:08:49.999 RssReaderTask: doInBackground: Processing... Trial: 1
2016-01-10 10:08:50.013 RssReaderTask: doInBackground: URL error
2016-01-10 10:08:50.027 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-10 10:08:50.871 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-10 10:08:51.014 RssReaderTask: doInBackground: Processing... Trial: 2
2016-01-10 10:08:51.025 RssReaderTask: doInBackground: URL error
2016-01-10 10:08:51.033 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-10 10:08:51.785 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-10 10:08:51.929 RssReaderTask: doInBackground: Processing... Trial: 3
2016-01-10 10:08:51.941 RssReaderTask: doInBackground: URL error
2016-01-10 10:08:51.959 RssReaderTask: onPostExecute: Failure
2016-01-10 10:09:25.304 NotificationsService: ********** Service created! **********
2016-01-10 10:09:28.654 NotificationsService: Time interval: 900 seconds
2016-01-10 10:09:28.763 NotificationsService: Internet connection active. Starting AsyncTasks...
2016-01-10 10:09:28.825 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-10 10:09:28.854 CheckMessagesTask: doInBackground: Processing... Trial: 1
2016-01-10 10:09:28.883 CheckMsgTask:getNumber: Trying: https://m.facebook.com/messages
2016-01-10 10:09:30.805 CheckMessagesTask: onPostExecute: Aight biatch ;)
2016-01-10 10:09:30.879 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-10 10:09:31.589 RssReaderTask: doInBackground: Processing... Trial: 1
2016-01-10 10:09:31.610 RssReaderTask: doInBackground: URL error
2016-01-10 10:09:31.626 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-10 10:09:32.522 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-10 10:09:32.766 RssReaderTask: doInBackground: Processing... Trial: 2
2016-01-10 10:09:32.782 RssReaderTask: doInBackground: URL error
2016-01-10 10:09:32.800 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-10 10:09:33.535 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-10 10:09:33.889 RssReaderTask: doInBackground: Processing... Trial: 3
2016-01-10 10:09:33.909 RssReaderTask: doInBackground: URL error
2016-01-10 10:09:33.935 RssReaderTask: onPostExecute: Failure

@pejakm
Copy link
Contributor

pejakm commented Jan 10, 2016

I can access https://web.facebook.com/notifications in my browser just fine.

@pejakm
Copy link
Contributor

pejakm commented Jan 10, 2016

@indywidualny
Copy link
Owner

Well. Both urls don't work. It's so strange. I will add user agent logging because user agent seems to be the problem here. At least one url should work, depending on your connection type.

At least now we know what is exactly the problem - feed url cannot be generated.

@creativetrendsapps what notifications url are you using in your app?

Has someone any ideas?

My logs:

2016-01-10 15:34:20.233 NotificationsService: ********** Service created! **********
2016-01-10 15:34:23.292 NotificationsService: Time interval: 900 seconds
2016-01-10 15:34:23.339 NotificationsService: I'm going to wait. Resuming in: 514 seconds
2016-01-10 15:47:00.933 NotificationsService: Lock is now released
2016-01-10 15:47:01.006 NotificationsService: Internet connection active. Starting AsyncTasks...
2016-01-10 15:47:01.056 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-10 15:47:01.091 CheckMessagesTask: doInBackground: Processing... Trial: 1
2016-01-10 15:47:01.121 CheckMsgTask:getNumber: Trying: https://m.facebook.com/messages
2016-01-10 15:47:02.273 NotificationsService: Start notification. isMessage: true
2016-01-10 15:47:02.357 CheckMessagesTask: onPostExecute: Aight biatch ;)
2016-01-10 15:47:02.451 RssReaderTask: doInBackground: Processing... Trial: 1
2016-01-10 15:47:03.205 RssReaderTask: onPostExecute: Aight biatch ;)

@pejakm
Copy link
Contributor

pejakm commented Jan 10, 2016

I've changed user agent to match my phone browser's (Lightning Browser). Still the same error. Anything else I can do to find out why "URL error" is happening?

@indywidualny
Copy link
Owner

I have no idea. But I'm thinking all the time. I will try to use the webview's user agent, because it's where we are logged in to Facebook. It may fix it.

Every MainActivity start this string will be saved to preferences (WebView can be upgraded). The service will get it during every checking task.

It's better than creating a new (pretty big) WebView object inside the service - this way it will still use only ~3 - 11 MB od RAM.

@indywidualny
Copy link
Owner

@pejakm Try this. With logging enabled.
https://github.com/indywidualny/FaceSlim/blob/4823a684cf8e156851088f0cc85a0aa59bbf35cc/app/app-release.apk [updated: Log connection type]

If you are using Google Chrome (mobile) you can check these addresses:
view-source:https://www.facebook.com/notifications
view-source:https://web.facebook.com/notifications

When something is wrong you cannot find an element "RSS Feed". At least one URL should work.

indywidualny pushed a commit that referenced this issue Jan 11, 2016
@pejakm
Copy link
Contributor

pejakm commented Jan 11, 2016

2016-01-11 14:29:28.590 NotificationsService: ********** Service created! **********
2016-01-11 14:29:31.979 NotificationsService: Time interval: 300 seconds
2016-01-11 14:29:32.113 NotificationsService: Internet connection active. Starting AsyncTasks...
2016-01-11 14:29:32.133 NotificationsService: Connection Type: Wi-Fi
2016-01-11 14:29:32.176 NotificationsService: User Agent: Mozilla/5.0 (Linux; Android 5.1.1; Build/LYZ28N) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36
2016-01-11 14:29:32.258 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-11 14:29:32.279 CheckMessagesTask: doInBackground: Processing... Trial: 1
2016-01-11 14:29:32.404 CheckMsgTask:getNumber: Trying: https://m.facebook.com/messages
2016-01-11 14:29:34.041 CheckMessagesTask: onPostExecute: Aight biatch ;)
2016-01-11 14:29:34.236 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-11 14:29:35.001 RssReaderTask: doInBackground: Processing... Trial: 1
2016-01-11 14:29:35.035 RssReaderTask: doInBackground: URL error
2016-01-11 14:29:35.069 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-11 14:29:36.929 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-11 14:29:37.156 RssReaderTask: doInBackground: Processing... Trial: 2
2016-01-11 14:29:37.200 RssReaderTask: doInBackground: URL error
2016-01-11 14:29:37.229 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-11 14:29:38.643 RssReaderTask:getFeed: Trying: https://web.facebook.com/notifications
2016-01-11 14:29:39.200 RssReaderTask: doInBackground: Processing... Trial: 3
2016-01-11 14:29:39.235 RssReaderTask: doInBackground: URL error
2016-01-11 14:29:39.290 RssReaderTask: onPostExecute: Failure

@pejakm
Copy link
Contributor

pejakm commented Jan 11, 2016

I've checked the source, there's no "RSS Feed" line anywhere. There's only "РСС" ("RSS" written in Cyrillic script). I'm using Facebook in Serbian, could this be the cause?

@pejakm
Copy link
Contributor

pejakm commented Jan 11, 2016

  2016-01-11 15:04:57.671 NotificationsService: ********** Service created! **********
2016-01-11 15:05:00.838 NotificationsService: Time interval: 300 seconds
2016-01-11 15:05:00.926 NotificationsService: Internet connection active. Starting AsyncTasks...
2016-01-11 15:05:00.943 NotificationsService: Connection Type: Wi-Fi
2016-01-11 15:05:00.970 NotificationsService: User Agent: Mozilla/5.0 (Linux; Android 5.1.1; Build/LYZ28N) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/39.0.0.0 Mobile Safari/537.36
2016-01-11 15:05:01.019 RssReaderTask:getFeed: Trying: https://www.facebook.com/notifications
2016-01-11 15:05:01.033 CheckMessagesTask: doInBackground: Processing... Trial: 1
2016-01-11 15:05:01.055 CheckMsgTask:getNumber: Trying: https://m.facebook.com/messages
2016-01-11 15:05:02.696 CheckMessagesTask: onPostExecute: Aight biatch ;)
2016-01-11 15:05:02.752 RssReaderTask: doInBackground: Processing... Trial: 1
2016-01-11 15:05:03.997 NotificationsService: Start notification - isMessage: false
2016-01-11 15:05:04.270 RssReaderTask: onPostExecute: Aight biatch ;)

Yes, I was right! I switched my Facebook to US English, and immediatelly I got a notification. :)

@indywidualny
Copy link
Owner

Awesome! Here is my solution. I will buy some beers and spend the night switching languages and checking "RSS" word in different languages. Next I will create an enum with all the records and their locales.

The app will get the right word basing on device locale. The only problem occurs when someone is using Facebook in a different language than a language of his device.

Has someone a better idea?

@pejakm
Copy link
Contributor

pejakm commented Jan 11, 2016

Has someone a better idea?

You need to find what? The link? Just the word? This is a relevant part of the code, right?
<a href="/feeds/notifications.php?id=1295895653&amp;viewer=blaah&amp;key=blahblah&amp;format=rss20">РСС</a>
for Serbian and
<a href="/feeds/notifications.php?id=1295895653&amp;viewer=blaah&amp;key=blahblah&amp;format=rss20">RSS</a>
for English? Can you match something other than the plain text "RSS"?

@pejakm
Copy link
Contributor

pejakm commented Jan 11, 2016

I will test the following change at this line:

add a[href]:matches(rss20) instead of a:matches(RSS)

Edit: Nope, failed.
Edit 2: Solution was, actually, quite easy.

indywidualny added a commit that referenced this issue Jan 12, 2016
Fix notifications for Facebook in other languages. Closes #78
@Coehill
Copy link

Coehill commented Jan 13, 2017

Hey, how exactly do I enable message notifications from within the app?

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

No branches or pull requests

6 participants