博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
APNS MySQL Tables
阅读量:5829 次
发布时间:2019-06-18

本文共 5141 字,大约阅读时间需要 17 分钟。

Before you get started: You can download this source code .

NOTE: If you do not have full database privileges, you will need to use our . You will NOT need the `apns_device_history` table as it will no longer be used, so you can ignore the instructions below. See  for further information.

There are only three tables you need to create to get Easy APNs up and running. `apns_device_history` is an optional table that should only be installed if you have full database privileges.

Table 1: apns_device_history (optional)

This table keeps track of each time an app is launched. This particular table only gets populated when a device already exists in the apns_devices table. With this data, you can keep track of when the user turned on/off notifications, how often then launch the app... etc. Pretty handy to have in our opinion.

1 CREATE TABLE `apns_device_history` (
2   `pid` int(9) unsigned NOT NULL auto_increment,
3   `appname` varchar(255) NOT NULL,
4   `appversion` varchar(25) default NULL,
5   `deviceuid` char(40) NOT NULL,
6   `devicetoken` char(64) NOT NULL,
7   `devicename` varchar(255) NOT NULL,
8   `devicemodel` varchar(100) NOT NULL,
9   `deviceversion` varchar(25) NOT NULL,
10   `pushbadge` enum('disabled','enabled') default 'disabled',
11   `pushalert` enum('disabled','enabled') default 'disabled',
12   `pushsound` enum('disabled','enabled') default 'disabled',
13   `development` enum('production','sandbox') character set latin1 NOT NULL default 'production',
14   `status` enum('active','uninstalled') NOT NULL default 'active',
15   `archived` datetime NOT NULL,
16   PRIMARY KEY  (`pid`),
17   KEY `devicetoken` (`devicetoken`),
18   KEY `devicename` (`devicename`),
19   KEY `devicemodel` (`devicemodel`),
20   KEY `deviceversion` (`deviceversion`),
21   KEY `pushbadge` (`pushbadge`),
22   KEY `pushalert` (`pushalert`),
23   KEY `pushsound` (`pushsound`),
24   KEY `development` (`development`),
25   KEY `status` (`status`),
26   KEY `appname` (`appname`),
27   KEY `appversion` (`appversion`),
28   KEY `deviceuid` (`deviceuid`),
29   KEY `archived` (`archived`)
30 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Store unique device history';

Table 2: apns_devices (lines 31-48 optional)

This table keeps track of all unique devices registering for push notifications. We also keep track of the applications name and version number in case you are running multiple apps, you can see who is using what.

1 CREATE TABLE `apns_devices` (
2   `pid` int(9) unsigned NOT NULL auto_increment,
3   `appname` varchar(255) NOT NULL,
4   `appversion` varchar(25) default NULL,
5   `deviceuid` char(40) NOT NULL,
6   `devicetoken` char(64) NOT NULL,
7   `devicename` varchar(255) NOT NULL,
8   `devicemodel` varchar(100) NOT NULL,
9   `deviceversion` varchar(25) NOT NULL,
10   `pushbadge` enum('disabled','enabled') default 'disabled',
11   `pushalert` enum('disabled','enabled') default 'disabled',
12   `pushsound` enum('disabled','enabled') default 'disabled',
13   `development` enum('production','sandbox') character set latin1 NOT NULL default 'production',
14   `status` enum('active','uninstalled') NOT NULL default 'active',
15   `created` datetime NOT NULL,
16   `modified` timestamp NOT NULL default '0000-00-00 00:00:00' on update CURRENT_TIMESTAMP,
17   PRIMARY KEY  (`pid`),
18   UNIQUE KEY `appname` (`appname`,`appversion`,`deviceuid`),
19   KEY `devicetoken` (`devicetoken`),
20   KEY `devicename` (`devicename`),
21   KEY `devicemodel` (`devicemodel`),
22   KEY `deviceversion` (`deviceversion`),
23   KEY `pushbadge` (`pushbadge`),
24   KEY `pushalert` (`pushalert`),
25   KEY `pushsound` (`pushsound`),
26   KEY `development` (`development`),
27   KEY `status` (`status`),
28   KEY `created` (`created`),
29   KEY `modified` (`modified`)
30 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Store unique devices';
31 DELIMITER ;;
32 CREATE TRIGGER `Archive` BEFORE UPDATE ON `apns_devices` FOR EACH ROW INSERT INTO `apns_device_history` VALUES (
33     NULL,
34     OLD.`appname`,
35     OLD.`appversion`,
36     OLD.`deviceuid`,
37     OLD.`devicetoken`,
38     OLD.`devicename`,
39     OLD.`devicemodel`,
40     OLD.`deviceversion`,
41     OLD.`pushbadge`,
42     OLD.`pushalert`,
43     OLD.`pushsound`,
44     OLD.`development`,
45     OLD.`status`,
46     NOW()
47 );;
48 DELIMITER ;

Table 3: apns_messages

This is where the messages you send to the user will go. By default, Easy APNs is setup to store the messages in queue and not actually deliver them until instructed elsewhere. This is where you would setup a cron job to process the data that still needs to be delivered.

1 CREATE TABLE `apns_messages` (
2   `pid` int(9) unsigned NOT NULL auto_increment,
3   `fk_device` int(9) unsigned NOT NULL,
4   `message` varchar(255) NOT NULL,
5   `delivery` datetime NOT NULL,
6   `status` enum('queued','delivered','failed') character set latin1 NOT NULL default 'queued',
7   `created` datetime NOT NULL,
8   `modified` timestamp NOT NULL default '0000-00-00 00:00:00' on update CURRENT_TIMESTAMP,
9   PRIMARY KEY  (`pid`),
10   KEY `fk_device` (`fk_device`),
11   KEY `status` (`status`),
12   KEY `created` (`created`),
13   KEY `modified` (`modified`),
14   KEY `message` (`message`),
15   KEY `delivery` (`delivery`)
16 ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COMMENT='Messages to push to APNS';

转载地址:http://bfldx.baihongyu.com/

你可能感兴趣的文章
韩国三月_热心的韩国朋友
查看>>
maven - 下载jar包
查看>>
对象字段与json下划线字段的相互转换
查看>>
英语听力/口语网站
查看>>
php------数组函数
查看>>
openfire 3.8.1 的JDK陷阱
查看>>
nginx init.d script
查看>>
这是不是PHP的bug
查看>>
2011 IT公司笔试面试题目整理
查看>>
Nginx源码解析- http模块分析
查看>>
手机自动化测试:Appium源码分析之跟踪代码分析九 1
查看>>
GBin1分享:jQuery1.7 Beta 预览
查看>>
ubuntu 14.04.1 vsftpd安装及我的配置过程
查看>>
python之变量
查看>>
Centos7单台服务器搭建FastDFS+Nginx
查看>>
python连接mysql
查看>>
Linux基础命令及快捷方式(未完版)
查看>>
fastdfs学习二————集群各项测试
查看>>
详解linux搭建DNS服务器器
查看>>
rhel7设置时区
查看>>