Push Notifications

Started by vbgamer45, February 01, 2019, 05:29:54 AM

Previous topic - Next topic

vbgamer45

Yeah it is based on member id thats how notifications gets sent to right person. I add member id as a filter from onesignal.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

addlife

Is it possible to have the button only displayed on a certain page? For example I would create a thread titled "Push Notifications" then on that page the button will show up.

vbgamer45

yes but you would have to change the logic for it.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

refx

Quote from: vbgamer45 on February 15, 2019, 10:30:49 AM
Yeah it is based on member id thats how notifications gets sent to right person. I add member id as a filter from onesignal.

Hello,
I've installed the plugin, after copying .js files to root, it started working (before that I got 404 errors on onesignal panel). But I got many user reports who are unable to subscribe. When I check oneSignal users/allusers page, under tags column,  While I get couple of user id and uname correct, I see that there are multiple entries tagged "{uid: 0}" with different player ids. Also most of the tags are empty, totally blank tag information. App Version column is also completely blank.

Any ideas what's wrong with my installation?

Christopher Scott Case

@vbgamer45 Hey, I've noticed that on replies to forum messages, I get notified when I reply to a topic I started, not just other people. It's annoying enough both myself and several of my users have decided not to use the notifications, because it's frustrating to get that extra notification.

If you can point me in the right direction, I'll gladly make the modification to filter out self replies myself. I was looking at the code, and I think I see where you're setting up a filter by user id, but as a JS dev with little PHP knowledge (and no SMF modding knowledge), I might not be following it correctly.

Biology Forums

Quote from: Christopher Scott Case on August 09, 2019, 12:27:38 PM
@vbgamer45 Hey, I've noticed that on replies to forum messages, I get notified when I reply to a topic I started, not just other people. It's annoying enough both myself and several of my users have decided not to use the notifications, because it's frustrating to get that extra notification.

If you can point me in the right direction, I'll gladly make the modification to filter out self replies myself. I was looking at the code, and I think I see where you're setting up a filter by user id, but as a JS dev with little PHP knowledge (and no SMF modding knowledge), I might not be following it correctly.

Let me get this straight, you start a topic, you reply to your topic, then you get notified (that's odd)
However, when others reply to your topic, you do not get notified (another oddity). Am I reading this correctly?

grzeg8102

Hi vbgamer45!
First of all - great mod! SMF lacks such basic and common functionalities as web push, so this mod is really useful.

I wanted to report some bugs to you. They relate to the @mentions mod. There are a couple of issues - all related to the @mentions mod you provide support to:
1. mod installation file contains an error.
File 'webpush2.xml' contans:
<file name="$languagedir/Mentions.php" error="skip">
should contain:
<file name="$sourcedir/Mentions.php" error="skip">
This mistake basically adds no support for the mentions mod during installation of push notifications

2. There's a bug in the code to be modified inside Mentions.php resulting in a syntax error - HTTP 500 durin execution of the PHP code
File 'webpush2.xml' contans:
$pushurl = $scripturl . '?msg=" . $id_post];
should contain:
$pushurl = $scripturl . '?msg=' . $id_post];

3. and the last bug in the code to be modified inside Mentions.php. There are no title nor message body parameters passed in callup of function webpush_send. The push notification when someone mentions the user is empty
File 'webpush2.xml' contans:
webpush_send($mention['id'], $user_info['id'], $user_info['name'],'tag',$pushurl);
should contain:
webpush_send($mention['id'], $user_info['id'], $user_info['name'],'tag',$pushurl, array('message'=>$subject, 'title'=>''));

vbgamer45

Fixed and  updated! Thanks for the fixes

1.0.1 Fixed some bugs for mentions mod support thanks to grzeg8102
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

pocttopus

Hello,

This updated modification renames public_html/Sources/Mentions.php file and forum is going down.
I had no other option and I had to remove it somehow and reinstall @mentions mod again.

sam666

Same issue with updated mod, breaks forum  :-X

vbgamer45

Quote from: pocttopus on September 20, 2019, 05:58:41 AM
Hello,

This updated modification renames public_html/Sources/Mentions.php file and forum is going down.
I had no other option and I had to remove it somehow and reinstall @mentions mod again.
What do you mean by renames? How does it change?
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

sam666

#51
I get the following error after installing. Running PHP7.1.30 SMF 2.0.15
Parse error: syntax error, unexpected 'id' (T_STRING) in */Sources/Mentions.php on line 256

webpush_send($mention['id'],$user_info['id'],$user_info['name'],'tag',$pushurl, array('message'=>$subject, 'title'=>''));

vbgamer45

Posted a new update to fix this issue.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

sam666

Installed with no errors. Thanks vbgamer45. Not had chance to test the bug fixes yet though.

vbgamer45

1.0.1a
+Added support for SMF 1.1.x
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

grzeg8102

Hi vbgamer,
I've spotted another small bug for push notifications. It bugged me for months why the website opened by push notifications shows the 1st page of a thread rather than navigating directly to the reply and today I found this.
<file name="$sourcedir/Subs-Post.php">

<operation>
<search position="replace"><![CDATA[trackStats(array('posts' => '+'));]]></search>
<add><![CDATA[trackStats(array('posts' => '+'));

// Push Notifications Mod SMFHacks.com
global $sourcedir, $scripturl;
require_once($sourcedir . '/webpush2.php');
$pushurl = $scripturl . '?topic=' . $topicOptions['id']. ".msg=" . $msgOptions['id'];

Last line contains a misformed parameter for the SMF forum, which the forum is unable to understand and opens the 1st page. The last line should look like this:

$pushurl = $scripturl . '?topic=' . $topicOptions['id']. ".msg" . $msgOptions['id'] . '.html#msg' . $msgOptions['id'];

So basically no `=` sign is necessary for the msg id. This makes the forum to navigate to the biginning of the right page with the last reply. However ideally we'd love to see the reply content from the push notification, right? And that's why we need to use the anchor in the link, so `#msgXXXX`.
After that the link is formatted correctly enough to be interpreted correctly bo SMF and opens the right URL with the reply.

Arantor

Um. You're both kind of wrong :/

The correct line would actually be:
$pushurl = $scripturl . '?topic=' . $topicOptions['id']. ".msg" . $msgOptions['id'] . "#msg" . $msgOptions['id'];

Any use of '.html' in SMF URLs is only valid for queryless URLs which is not the default, not used throughout the rest of SMF and only implemented as a last-minute replacement in the buffer (i.e. almost none of SMF actually outputs .html URLs, it outputs the URLs of the format I outlined and is converted *only* if that option is turned on, last minute before sending the page to the browser.

And of no benefit to modern search engines.

vbgamer45

I think I had an issue sending the # which I why I took it I could be wrong though don't remember. Give it a try though and let me know.
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Arantor

Even if you have no # in it, you need to not have .msg= in the URL but .msg123 as that's what SMF picks up.

vbgamer45

Update
1.0.1b
!Minor url for forum posts fix thanks to Arantor.



Note didn't add the # in the url
Community Suite for SMF - Take your forum to the next level built for SMF, Gallery,Store,Classifieds,Downloads,more!

SMFHacks.com -  Paid Modifications for SMF

Mods:
EzPortal - Portal System for SMF
SMF Gallery Pro
SMF Store SMF Classifieds Ad Seller Pro

Advertisement: