-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathappp-custom-push.php
109 lines (86 loc) · 2.67 KB
/
appp-custom-push.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
<?php
/*
Plugin Name: AppPresser Custom Push
Plugin URI: http://apppresser.com
Description: An AppPush add-on for customizing push notification sent through your myapppresser.com account
Version: 1.0.0
Author: AppPresser Team
Author URI: http://apppresser.com
License: GPLv2
*/
/*
This program is free software; you can redistribute it and/or
modify it under the terms of the GNU General Public License
as published by the Free Software Foundation; either version 2
of the License, or (at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
*/
class AppPresserCustomPush {
const VERSION = '1.0.0';
public function hooks() {
add_filter( 'ap3_send_push_data', array( $this, 'custom_push__android' ) );
add_filter( 'ap3_send_push_data', array( $this, 'custom_push__ios' ) );
}
public function custom_push__ios( $data ) {
if( !isset( $data['custom'] ) ) {
$data['custom'] = array();
}
/**
* Sample:
*
* Overwrite the title and message for iOS only.
*
*/
$data['custom']['ios'] = array(
'subtitle' => 'Test subtitle',
'title' => 'ios overwrite the title',
'alert' => 'ios overwrite the message',
);
$data['custom']['default_msg'] = "Overwrite iOS default message";
return $data;
}
public function custom_push__android( $data ) {
if(
isset(
$_POST,
$_POST['send_push_notification'],
$_POST['_thumbnail_id'],
$_POST['ID']
)
&& $_POST['send_push_notification'] === '1'
) {
$thumb_url = get_the_post_thumbnail_url( $_POST['ID'] );
if( $thumb_url ) {
if( !isset( $data['custom'] ) ) {
$data['custom'] = array();
}
/**
* Sample:
*
* Overwrite the title and message for Android only plus
* adds the thumbnail.
*
*/
$data['custom']['android'] = array(
'summaryText' => get_the_excerpt( $_POST['ID'] ),
'title' => 'android overwrite the title',
'message' => 'android overwrite the message',
'style' => 'picture',
'picture' => $thumb_url, // big image
'image' => $thumb_url, // right side little image
// 'image-type' => 'circle',
// 'vibrationPattern' => array( 0, 500, 1000, 500 ), // some phones
);
}
}
return $data;
}
}
$apppImagePush = new AppPresserCustomPush();
$apppImagePush->hooks();