Skip to content

Commit fbb5482

Browse files
committed
Completed Notifications
1 parent 7ea68b0 commit fbb5482

File tree

2 files changed

+23
-21
lines changed

2 files changed

+23
-21
lines changed

packet/notifications.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,14 @@
11
import onesignal
2-
from . import app, onesignal_client
2+
3+
from packet import app, onesignal_client
4+
from packet.models import NotificationSubscription
35

46
post_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())

packet/templates/include/head.html

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -38,27 +38,27 @@
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

0 commit comments

Comments
 (0)