@@ -31,8 +31,8 @@ def simple_push_to_specific_followers_example(self):
3131 """
3232 followers = [self .__resource .user_id ]
3333 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"
3636 " the link or tagging them in the comments." ,
3737 push_to_followers = followers
3838 )
@@ -53,9 +53,10 @@ def simple_push_to_specific_phone_numbers_and_emails_example(self):
5353 # TODO- Replace with a real email.
5454 emails = ['fake.email@fake.com' ]
5555 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." ,
5960 push_to_phone_numbers = phone_numbers ,
6061 push_to_emails = emails
6162 )
@@ -83,7 +84,7 @@ def specific_followers_and_channel_example(self):
8384 self .__resource .create_channel ("Test channel" )
8485 followers = [self .__resource .user_id ]
8586 response = self .__resource .push (
86- f"Hello to { followers [0 ]} " ,
87+ content = f"Hello to { followers [0 ]} " ,
8788 channel_name = "Test channel" ,
8889 push_to_followers = followers
8990 )
@@ -107,104 +108,126 @@ def scheduled_push(self):
107108 Schedules a push notification for one hour from the current time.
108109 :return: the result of the call to push
109110 """
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+ )
112115
113116 def immediate_expiration_push (self ):
114117 """
115118 Sends a push notification and sets the expiration for the current time. Because our expiration function
116119 polls approximately every 15-30 minutes, the notification will delete within 30 minutes.
117120 :return: the result of the call to push
118121 """
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+ )
121126
122127 def expire_one_hour_after_schedule (self ):
123128 """
124129 Schedules a push notification for one hour from now, and then expires it one hour later.
125130 :return: the result of the call to push
126131 """
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+ )
130137
131138 def subtitle_body_example (self ):
132139 """
133140 Sends a push notification with a subtitle and a body.
134141 :return: the result of the call to push
135142 """
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+ )
147157
148158 def post_a_link_ex_1 (self ):
149159 """
150160 Sends a push notification with a link to Jack Dorsey's first tweet. should_open_link_in_app is set to False
151161 so that the Twitter app opens (rather than opening twitter.com within the Spontit app).
152162 :return: the result of the call to push
153163 """
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+ )
162175
163176 def post_a_link_ex_2 (self ):
164177 """
165178 Sends a push notification with a link to Amazon.com.
166179 :return: the result of the call to push
167180 """
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+ )
170185
171186 def post_a_link_ex_3 (self ):
172187 """
173188 Sends a push notification linking the Spontit review compose window in the App Store. should_open_link_in_app is
174189 set to False so that the App Store opens.
175190 :return: the result of the call to push
176191 """
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+ )
181198
182199 def post_an_ios_deep_link_ex_1 (self ):
183200 """
184201 Sends a push notification deep linking to Stocks app.
185202 Only works for iOS Spontit App, >= v6.0.1
186203 :return: the result of the call to push
187204 """
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+ )
190209
191210 def post_an_ios_deep_link_ex_2 (self ):
192211 """
193212 Sends a push notification deep linking to the gallery tab of the Shortcuts app.
194213 Only works for iOS Spontit App, >= v6.0.1
195214 :return: the result of the call to push
196215 """
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+ )
199220
200221 def post_an_ios_deep_link_ex_3 (self ):
201222 """
202223 Pushes a notification that deep links to the Spontit review creation window in the App Store.
203224 :return: the result of the call to push
204225 """
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+ )
208231
209232 def create_new_channel (self ):
210233 """
@@ -370,6 +393,7 @@ def do_everything(self):
370393 # Get your userId at spontit.com/profile
371394 # Get your secretKey at spontit.com/secret_keys
372395 spontit_src = SpontitResource ("my_user_id" , "my_secret_key" )
396+
373397 example_instance = Examples (spontit_src )
374398
375399 push_response = example_instance .simple_push_example ()
0 commit comments