OneSignalUtil.py 文件源码

python
阅读 19 收藏 0 点赞 0 评论 0

项目:restful-api 作者: TeamGhostBuster 项目源码 文件源码
def create_invitation_notification(self, invitations):
        target_users = list()
        for each in invitations:
            target_users.append({'field': 'tag', 'key': 'email', 'relation': '=', 'value': each.invitee.email})
            target_users.append({'operator': 'OR'})

        payload = {
            'app_id': app.config['ONE_SIGNAL_SETTINGS']['API_ID'],
            'filters': target_users,
            'contents': {'en': '{} sent you a invitation'.format(invitations[0].inviter.first_name)}
        }

        req = requests.post('https://onesignal.com/api/v1/notifications',
                            headers=self.header,
                            data=json.dumps(payload))

        if req.status_code == 200:
            app.logger.info('Push notification sent')
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号