@@ -31,8 +31,8 @@ def simple_push_to_specific_followers_example(self):
31
31
"""
32
32
followers = [self .__resource .user_id ]
33
33
response = self .__resource .push (
34
- "Hello to myself!" ,
35
- body = "No one else can see this until I specifically share it with them, by either sharing"
34
+ push_content = "Hello to myself!" ,
35
+ content = "No one else can see this until I specifically share it with them, by either sharing"
36
36
" the link or tagging them in the comments." ,
37
37
push_to_followers = followers
38
38
)
@@ -53,9 +53,10 @@ def simple_push_to_specific_phone_numbers_and_emails_example(self):
53
53
# TODO- Replace with a real email.
54
54
emails = ['fake.email@fake.com' ]
55
55
response = self .__resource .push (
56
- "Hello to other users!" ,
57
- body = "Add any phone numbers or emails to this push. Tell users to sign up on Spontit with the same "
58
- "phone number / email as they signed up with using your service. Then you can push directly to them." ,
56
+ push_content = "Hello to other users!" ,
57
+ content = "Add any phone numbers or emails to this push. Tell users to sign up on Spontit with the same "
58
+ "phone number / email as they signed up with using your service. Then you can push directly to "
59
+ "them." ,
59
60
push_to_phone_numbers = phone_numbers ,
60
61
push_to_emails = emails
61
62
)
@@ -83,7 +84,7 @@ def specific_followers_and_channel_example(self):
83
84
self .__resource .create_channel ("Test channel" )
84
85
followers = [self .__resource .user_id ]
85
86
response = self .__resource .push (
86
- f"Hello to { followers [0 ]} " ,
87
+ content = f"Hello to { followers [0 ]} " ,
87
88
channel_name = "Test channel" ,
88
89
push_to_followers = followers
89
90
)
@@ -107,104 +108,126 @@ def scheduled_push(self):
107
108
Schedules a push notification for one hour from the current time.
108
109
:return: the result of the call to push
109
110
"""
110
- return self .__resource .push ("Hello, in 1 hour" ,
111
- schedule_time_stamp = int (time .time ()) + 3600 )
111
+ return self .__resource .push (
112
+ content = "Hello, in 1 hour" ,
113
+ schedule_time_stamp = int (time .time ()) + 3600
114
+ )
112
115
113
116
def immediate_expiration_push (self ):
114
117
"""
115
118
Sends a push notification and sets the expiration for the current time. Because our expiration function
116
119
polls approximately every 15-30 minutes, the notification will delete within 30 minutes.
117
120
:return: the result of the call to push
118
121
"""
119
- return self .__resource .push ("Hello, expire ASAP (within 15 minutes)" ,
120
- expiration = SpontitResource .Expiration (0 , 0 , 0 ))
122
+ return self .__resource .push (
123
+ content = "Hello, expire ASAP (within 15 minutes)" ,
124
+ expiration = SpontitResource .Expiration (0 , 0 , 0 )
125
+ )
121
126
122
127
def expire_one_hour_after_schedule (self ):
123
128
"""
124
129
Schedules a push notification for one hour from now, and then expires it one hour later.
125
130
:return: the result of the call to push
126
131
"""
127
- return self .__resource .push ("Hello, in 1 hour. Bye in 2." ,
128
- schedule_time_stamp = int (time .time ()) + 3600 ,
129
- expiration = SpontitResource .Expiration (days = 0 , hours = 1 , minutes = 0 ))
132
+ return self .__resource .push (
133
+ content = "Hello, in 1 hour. Bye in 2." ,
134
+ schedule_time_stamp = int (time .time ()) + 3600 ,
135
+ expiration = SpontitResource .Expiration (days = 0 , hours = 1 , minutes = 0 )
136
+ )
130
137
131
138
def subtitle_body_example (self ):
132
139
"""
133
140
Sends a push notification with a subtitle and a body.
134
141
:return: the result of the call to push
135
142
"""
136
- return self .__resource .push ("Hello!" ,
137
- ios_subtitle = "An API Notice" ,
138
- body = "This is a body. You can write up to 500 characters "
139
- "in the body. The body does not show up in the push "
140
- "notification. The body only appears once the user "
141
- "opens the notification with their mobile phone. Currently,"
142
- " the body only shows on iOS devices, but we will change "
143
- "this soon. As a side note, the subtitle only shows on "
144
- "the push notification, but does not show when the user "
145
- "opens the app. Currently, the subtitle is only supported "
146
- "for iOS devices." )
143
+ my_content = "This is a body. You can write up to 500 characters " \
144
+ "in the body. The body does not show up in the push " \
145
+ "notification. The body only appears once the user " \
146
+ "opens the notification with their mobile phone. Currently," \
147
+ " the body only shows on iOS devices, but we will change " \
148
+ "this soon. As a side note, the subtitle only shows on " \
149
+ "the push notification, but does not show when the user " \
150
+ "opens the app. Currently, the subtitle is only supported " \
151
+ "for iOS devices."
152
+ return self .__resource .push (
153
+ push_content = "Hello!" ,
154
+ ios_subtitle = "An API Notice" ,
155
+ content = my_content
156
+ )
147
157
148
158
def post_a_link_ex_1 (self ):
149
159
"""
150
160
Sends a push notification with a link to Jack Dorsey's first tweet. should_open_link_in_app is set to False
151
161
so that the Twitter app opens (rather than opening twitter.com within the Spontit app).
152
162
:return: the result of the call to push
153
163
"""
154
- return self .__resource .push ("Jack's first tweet." ,
155
- link = "https://twitter.com/jack/status/20" ,
156
- should_open_link_in_app = False ,
157
- body = "This link does not open within the app. The purpose "
158
- "is that we want the Twitter app to open. If set "
159
- "should_open_link_in_app to True, then the link would "
160
- "open within the Spontit app and the app would not "
161
- "launch." )
164
+ my_content = "This link does not open within the app. The purpose " \
165
+ "is that we want the Twitter app to open. If set " \
166
+ "should_open_link_in_app to True, then the link would " \
167
+ "open within the Spontit app and the app would not " \
168
+ "launch."
169
+ return self .__resource .push (
170
+ push_content = "Jack's first tweet." ,
171
+ link = "https://twitter.com/jack/status/20" ,
172
+ should_open_link_in_app = False ,
173
+ content = my_content
174
+ )
162
175
163
176
def post_a_link_ex_2 (self ):
164
177
"""
165
178
Sends a push notification with a link to Amazon.com.
166
179
:return: the result of the call to push
167
180
"""
168
- return self .__resource .push ("Buy from Amazon." ,
169
- link = "https://amazon.com" )
181
+ return self .__resource .push (
182
+ push_content = "Buy from Amazon." ,
183
+ link = "https://amazon.com"
184
+ )
170
185
171
186
def post_a_link_ex_3 (self ):
172
187
"""
173
188
Sends a push notification linking the Spontit review compose window in the App Store. should_open_link_in_app is
174
189
set to False so that the App Store opens.
175
190
:return: the result of the call to push
176
191
"""
177
- return self .__resource .push ("Please rate Spontit in the App Store!" ,
178
- push_title = "Spontit Rating Request" ,
179
- link = "https://itunes.apple.com/app/id1448318683?action=write-review" ,
180
- should_open_link_in_app = False )
192
+ return self .__resource .push (
193
+ push_content = "Please rate Spontit in the App Store!" ,
194
+ push_title = "Spontit Rating Request" ,
195
+ link = "https://itunes.apple.com/app/id1448318683?action=write-review" ,
196
+ should_open_link_in_app = False
197
+ )
181
198
182
199
def post_an_ios_deep_link_ex_1 (self ):
183
200
"""
184
201
Sends a push notification deep linking to Stocks app.
185
202
Only works for iOS Spontit App, >= v6.0.1
186
203
:return: the result of the call to push
187
204
"""
188
- return self .__resource .push ("Open the stocks app." ,
189
- ios_deep_link = "stocks://" )
205
+ return self .__resource .push (
206
+ push_content = "Open the stocks app." ,
207
+ ios_deep_link = "stocks://"
208
+ )
190
209
191
210
def post_an_ios_deep_link_ex_2 (self ):
192
211
"""
193
212
Sends a push notification deep linking to the gallery tab of the Shortcuts app.
194
213
Only works for iOS Spontit App, >= v6.0.1
195
214
:return: the result of the call to push
196
215
"""
197
- return self .__resource .push ("Open the gallery tab of the Shortcuts app." ,
198
- ios_deep_link = "shortcuts://gallery" )
216
+ return self .__resource .push (
217
+ push_content = "Open the gallery tab of the Shortcuts app." ,
218
+ ios_deep_link = "shortcuts://gallery"
219
+ )
199
220
200
221
def post_an_ios_deep_link_ex_3 (self ):
201
222
"""
202
223
Pushes a notification that deep links to the Spontit review creation window in the App Store.
203
224
:return: the result of the call to push
204
225
"""
205
- return self .__resource .push ("Please rate Spontit in the App Store!" ,
206
- push_title = "Spontit Rating Request" ,
207
- ios_deep_link = "itms-apps://itunes.apple.com/app/id1448318683?action=write-review" )
226
+ return self .__resource .push (
227
+ push_content = "Please rate Spontit in the App Store!" ,
228
+ push_title = "Spontit Rating Request" ,
229
+ ios_deep_link = "itms-apps://itunes.apple.com/app/id1448318683?action=write-review"
230
+ )
208
231
209
232
def create_new_channel (self ):
210
233
"""
@@ -370,6 +393,7 @@ def do_everything(self):
370
393
# Get your userId at spontit.com/profile
371
394
# Get your secretKey at spontit.com/secret_keys
372
395
spontit_src = SpontitResource ("my_user_id" , "my_secret_key" )
396
+
373
397
example_instance = Examples (spontit_src )
374
398
375
399
push_response = example_instance .simple_push_example ()
0 commit comments