File tree Expand file tree Collapse file tree 2 files changed +23
-21
lines changed
Expand file tree Collapse file tree 2 files changed +23
-21
lines changed Original file line number Diff line number Diff line change 11import onesignal
2- from . import app , onesignal_client
2+
3+ from packet import app , onesignal_client
4+ from packet .models import NotificationSubscription
35
46post_body = {
57 "content" : {"en" : "Default message" },
68 "headings" : {"en" : "Default Title" },
79 "included_segments" : ["Active Users" , "Inactive Users" ],
8- "chrome_web_icon" : app .config ["PROTOCOL" ] + app .config ["SERVER_NAME" ] + "/static/android-chrome-512x512.png" ,
9- "chrome_web_badge" : app .config ["PROTOCOL" ] + app .config ["SERVER_NAME" ] + "/static/android-chrome-512x512.png" ,
10+ "chrome_web_icon" : app .config ["PROTOCOL" ] + app .config ["SERVER_NAME" ] + "/static/android-chrome-512x512.png" ,
11+ "chrome_web_badge" : app .config ["PROTOCOL" ] + app .config ["SERVER_NAME" ] + "/static/android-chrome-512x512.png" ,
1012 "url" : app .config ["PROTOCOL" ] + app .config ["SERVER_NAME" ]
1113}
1214
@@ -40,7 +42,7 @@ def packet_100_percent_notification(packet):
4042 # TODO: Issue #156
4143 notification .post_body ["chrome_web_icon" ] = 'https://profiles.csh.rit.edu/image/' + packet .freshman_username
4244 notification .post_body ["include_player_ids" ] = tokens
43-
45+
4446 onesignal_response = onesignal_client .send_notification (notification )
4547 print (onesignal_response .status_code )
4648 print (onesignal_response .json ())
Original file line number Diff line number Diff line change 3838 < script src ="https://cdn.onesignal.com/sdks/OneSignalSDK.js " async =""> </ script >
3939 < script >
4040 var OneSignal = window . OneSignal || [ ] ;
41- OneSignal . push ( function ( ) {
41+ OneSignal . push ( function ( ) {
4242 OneSignal . init ( {
43- appId : "{{ config['ONESIGNAL_APP_ID'] }}" ,
44- autoResubscribe : true ,
43+ appId : "{{ config['ONESIGNAL_APP_ID'] }}" ,
44+ autoResubscribe : true ,
4545 allowLocalhostAsSecureOrigin : true ,
4646 } ) ;
4747 OneSignal . showNativePrompt ( ) ;
48- OneSignal . on ( "subscriptionChange" , function ( ) {
49- OneSignal . getUserId ( ) . then ( function ( result ) {
50- $ . ajax ( {
51- url : "/api/v1/subscribe/" ,
52- method : "POST" ,
53- data : {
54- token : result
55- } ,
56- success : function ( data ) {
57- console . log ( data ) ;
58- }
59- } ) ;
60- } ) ;
61- } ) ;
48+ OneSignal . on ( "subscriptionChange" , function ( ) {
49+ OneSignal . getUserId ( ) . then ( function ( result ) {
50+ $ . ajax ( {
51+ url : "/api/v1/subscribe/" ,
52+ method : "POST" ,
53+ data : {
54+ token : result
55+ } ,
56+ success : function ( data ) {
57+ console . log ( data ) ;
58+ }
59+ } ) ;
60+ } ) ;
61+ } ) ;
6262 } ) ;
6363 </ script >
6464
You can’t perform that action at this time.
0 commit comments