create a module inside web2py
API_Pusher.py
import pusher
def pusher_client():
return pusher.Pusher(
app_id='yourid',
key='yourkey',
secret='yoursecret',
cluster='eu',
ssl=True
)
Then inside your controllers
from API_Pusher import pusher_client
...
pusher_client().trigger('fileit', 'plannerPesos', {'message':
"PlaySound('ok')"})
Em sex., 20 de nov. de 2020 às 07:41, mostwanted <[email protected]>
escreveu:
> Hey Ramos, I was able to successfully register the app on pusher.com.
> towards step 4 its says i should copy this code:
> *CODE:*
> curl -H "Content-Type: application/json" \
> -H "Authorization: Bearer
> 9C9232906DFC6C8F8115926CC30D637945EB75F60467DA77977C399C4235E61C" \
> -X POST "
> https://733e2240-aca0-4a12-a5a9-c3b1422b9063.pushnotifications.pusher.com/publish_api/v1/instances/733e2240-aca0-4a12-a5a9-c3b1422b9063/publishes"
> \
> -d
> '{"interests":["hello"],"web":{"notification":{"title":"Hello","body":"Hello,
> world!"}}}'
>
> to my console! Which console is this one? My desktop console? I'm hosted
> with pythonanywhere.com, can i use the Bash console in my dashboard?
>
> On Tuesday, November 17, 2020 at 7:53:20 AM UTC+2 mostwanted wrote:
>
>> Thanks alot Ramos, think this will work, very little work needs to be
>> done here, I'll try it out.
>>
>> On Tuesday, November 17, 2020 at 1:06:10 AM UTC+2 Ramos wrote:
>>
>>> Why reiventing the wheel ???
>>> https://pusher.com/
>>>
>>> I use it with web2py and works like a charm
>>>
>>>
>>> Em seg., 16 de nov. de 2020 às 08:44, mostwanted <[email protected]>
>>> escreveu:
>>>
>>>> So far all I have been able achieve is asking the user for permission
>>>> to send them notifications & if they accept all that happens is that
>>>> everytime they open the app they get a greetings notification, achieving
>>>> that was not complicated because it was straight forward, I placed the code
>>>> in my main.js script & it runs everytime the service worker gets
>>>> registered.
>>>>
>>>> *CODE:*
>>>> Notification.requestPermission(result => {
>>>> if (result === 'granted') {
>>>> showNotification('Welcome to My App™', 'Everything Services™')
>>>> }
>>>> });
>>>>
>>>> function showNotification(title, message) {
>>>> if ('Notification' in window) {
>>>> navigator.serviceWorker.ready.then(registration => {
>>>> registration.showNotification(title, {
>>>> body: message,
>>>> tag: 'my-app',
>>>> icon:'/init/static/images/icon_192x192.png',
>>>> badge:'/init/static/images/icon_128x128.png',
>>>> vibrate: [200, 100, 200, 100, 200, 100]
>>>> });
>>>> });
>>>> }
>>>> }
>>>>
>>>>
>>>> On Monday, November 16, 2020 at 10:31:10 AM UTC+2 mostwanted wrote:
>>>>
>>>>>
>>>>> Has anyone been able to implement push notifications on their web2py
>>>>> apps?
>>>>>
>>>>> I need a working application with some examples on how to implement
>>>>> this for one of my applications.
>>>>>
>>>>> I've been looking at the "web-push-book (
>>>>> https://web-push-book.gauntface.com/how-push-works/)" but I cant put
>>>>> it together in my head.
>>>>>
>>>>> What I wanna achieve is relatively basic, I have an applivcation that
>>>>> offers information on services & products sold in my area, so what I want
>>>>> is to be able to send notifications everytime a new service or product is
>>>>> registered.
>>>>>
>>>>> If anyone has any idea on how I can easily implement this please help
>>>>> me.
>>>>>
>>>>> Regards;
>>>>>
>>>>> Mostwanted
>>>>>
>>>> --
>>>> Resources:
>>>> - http://web2py.com
>>>> - http://web2py.com/book (Documentation)
>>>> - http://github.com/web2py/web2py (Source code)
>>>> - https://code.google.com/p/web2py/issues/list (Report Issues)
>>>> ---
>>>> You received this message because you are subscribed to the Google
>>>> Groups "web2py-users" group.
>>>> To unsubscribe from this group and stop receiving emails from it, send
>>>> an email to [email protected].
>>>> To view this discussion on the web visit
>>>> https://groups.google.com/d/msgid/web2py/01da1065-f7d3-4394-9014-a424639bef03n%40googlegroups.com
>>>> <https://groups.google.com/d/msgid/web2py/01da1065-f7d3-4394-9014-a424639bef03n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>>> .
>>>>
>>> --
> Resources:
> - http://web2py.com
> - http://web2py.com/book (Documentation)
> - http://github.com/web2py/web2py (Source code)
> - https://code.google.com/p/web2py/issues/list (Report Issues)
> ---
> You received this message because you are subscribed to the Google Groups
> "web2py-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/web2py/ca28be9e-6720-4993-9f68-1a42cf57a2c1n%40googlegroups.com
> <https://groups.google.com/d/msgid/web2py/ca28be9e-6720-4993-9f68-1a42cf57a2c1n%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
>
--
Resources:
- http://web2py.com
- http://web2py.com/book (Documentation)
- http://github.com/web2py/web2py (Source code)
- https://code.google.com/p/web2py/issues/list (Report Issues)
---
You received this message because you are subscribed to the Google Groups
"web2py-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/web2py/CAEM0BxOhub4yx6rFTuuULdAs0Zn2%3DqK1g7Y_Zz-Qk92m-eX2Pg%40mail.gmail.com.