@@ -19,7 +19,64 @@ def simple_push_example(self):
19
19
Sends a simple push notification.
20
20
:return: the result of the call to push
21
21
"""
22
- return self .__resource .push ("Hello!" )
22
+ response = self .__resource .push ("Hello!" )
23
+ print (response )
24
+ return response
25
+
26
+ def simple_push_to_specific_followers_example (self ):
27
+ """
28
+ Sends a push notification to specifically you. You can specify which followers should receive the notification
29
+ as shown below. To list your followers, see the list_followers_example().
30
+ :return:
31
+ """
32
+ followers = [self .__resource .user_id ]
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"
36
+ " the link or tagging them in the comments." ,
37
+ push_to_followers = followers
38
+ )
39
+ print (response )
40
+ return response
41
+
42
+ def list_followers_example (self ):
43
+ """
44
+ Lists all your followers.
45
+ :return:
46
+ """
47
+ response = self .__resource .list_followers ()
48
+ print (response )
49
+ return response
50
+
51
+ def specific_followers_and_channel_example (self ):
52
+ """
53
+ Sends a push notification to a specific user following the channel. The user must be following the channel in
54
+ order to receive it. You can specify which followers should receive the notification as shown below. To list
55
+ your followers, see the list_followers_for_channel_example().
56
+ :return:
57
+ """
58
+ # Create the channel if it is not yet created.
59
+ self .__resource .create_channel ("Test channel" )
60
+ followers = [self .__resource .user_id ]
61
+ response = self .__resource .push (
62
+ f"Hello to { followers [0 ]} " ,
63
+ channel_name = "Test channel" ,
64
+ push_to_followers = followers
65
+ )
66
+ print (response )
67
+ return response
68
+
69
+ def list_followers_for_channel_example (self ):
70
+ """
71
+ Lists all your followers for this particular channel.
72
+ :return:
73
+ """
74
+ self .__resource .create_channel ("Test channel" )
75
+ response = self .__resource .list_followers (
76
+ channel_name = "Test channel"
77
+ )
78
+ print (response )
79
+ return response
23
80
24
81
def scheduled_push (self ):
25
82
"""
@@ -47,25 +104,13 @@ def expire_one_hour_after_schedule(self):
47
104
schedule_time_stamp = int (time .time ()) + 3600 ,
48
105
expiration = SpontitResource .Expiration (days = 0 , hours = 1 , minutes = 0 ))
49
106
50
- def rate_limit_example (self ):
51
- """
52
- Spontit currently only supports sending one push notification per second.
53
- This function throttles that limit as an example of what you can expect if you exceed that limit.
54
- :return: the final response of the 10 calls to push.
55
- """
56
- response_received = None
57
- for _ in range (10 ):
58
- response_received = self .simple_push_example ()
59
- print (response_received )
60
- return response_received
61
-
62
107
def subtitle_body_example (self ):
63
108
"""
64
109
Sends a push notification with a subtitle and a body.
65
110
:return: the result of the call to push
66
111
"""
67
112
return self .__resource .push ("Hello!" ,
68
- subtitle = "An API Notice" ,
113
+ ios_subtitle = "An API Notice" ,
69
114
body = "This is a body. You can write up to 500 characters "
70
115
"in the body. The body does not show up in the push "
71
116
"notification. The body only appears once the user "
@@ -106,6 +151,7 @@ def post_a_link_ex_3(self):
106
151
:return: the result of the call to push
107
152
"""
108
153
return self .__resource .push ("Please rate Spontit in the App Store!" ,
154
+ push_title = "Spontit Rating Request" ,
109
155
link = "https://itunes.apple.com/app/id1448318683?action=write-review" ,
110
156
should_open_link_in_app = False )
111
157
@@ -133,6 +179,7 @@ def post_an_ios_deep_link_ex_3(self):
133
179
:return: the result of the call to push
134
180
"""
135
181
return self .__resource .push ("Please rate Spontit in the App Store!" ,
182
+ push_title = "Spontit Rating Request" ,
136
183
ios_deep_link = "itms-apps://itunes.apple.com/app/id1448318683?action=write-review" )
137
184
138
185
def create_new_channel (self ):
@@ -264,8 +311,11 @@ def do_everything(self):
264
311
self .simple_push_example ,
265
312
self .scheduled_push ,
266
313
self .immediate_expiration_push ,
314
+ self .simple_push_to_specific_followers_example ,
315
+ self .list_followers_example ,
316
+ self .list_followers_for_channel_example ,
317
+ self .specific_followers_and_channel_example ,
267
318
self .expire_one_hour_after_schedule ,
268
- self .rate_limit_example ,
269
319
self .subtitle_body_example ,
270
320
self .post_a_link_ex_1 ,
271
321
self .post_a_link_ex_2 ,
0 commit comments