• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python urbanairship.notification函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Python中urbanairship.notification函数的典型用法代码示例。如果您正苦于以下问题:Python notification函数的具体用法?Python notification怎么用?Python notification使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了notification函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Python代码示例。

示例1: test_ios_unicode

    def test_ios_unicode(self):
        self.assertEqual(
            ua.notification(
                ios=ua.ios(
                    alert=u'Hello',
                    badge=u'+1',
                    expiry=u'time',
                )
            ),
            {
                'ios': {
                    'alert': 'Hello',
                    'badge': '+1',
                    'expiry': 'time'
                }
            }
        )

        self.assertEqual(
            ua.notification(
                ios=ua.ios(
                    content_available=True
                )
            ),
            {
                'ios': {
                    'content-available': True
                }
            }
        )
开发者ID:afresh1,项目名称:python-library,代码行数:30,代码来源:test_message.py


示例2: test_wns_payload

    def test_wns_payload(self):
        self.assertEqual(
            ua.notification(wns=ua.wns_payload(
                alert='Hello',
            )),
            {'wns': {
                'alert': 'Hello',
            }})

        self.assertEqual(
            ua.notification(wns=ua.wns_payload(
                toast={'key': 'value'},
            )),
            {'wns': {
                'toast': {'key': 'value'},
            }})

        self.assertEqual(
            ua.notification(wns=ua.wns_payload(
                tile={'key': 'value'},
            )),
            {'wns': {
                'tile': {'key': 'value'},
            }})

        self.assertEqual(
            ua.notification(wns=ua.wns_payload(
                badge={'key': 'Hello'},
            )),
            {'wns': {
                'badge': {'key': 'Hello'},
            }})
        self.assertRaises(ValueError, ua.wns_payload, alert='Hello',
            tile='Foo')
开发者ID:05bit,项目名称:python-urbanairship3,代码行数:34,代码来源:test_message.py


示例3: test_blackberry

    def test_blackberry(self):
        self.assertEqual(
            ua.notification(
                blackberry=ua.blackberry(
                    alert='Hello',
                )
            ),
            {
                'blackberry': {
                    'body': 'Hello',
                    'content_type': 'text/plain',
                }
            }
        )

        self.assertEqual(
            ua.notification(
                blackberry=ua.blackberry(
                    body='Hello',
                    content_type='text/html',
                )
            ),
            {
                'blackberry': {
                    'body': 'Hello',
                    'content_type': 'text/html',
                }
            }
        )
        self.assertRaises(
            ValueError,
            ua.blackberry,
            body='Hello'
        )
开发者ID:afresh1,项目名称:python-library,代码行数:34,代码来源:test_message.py


示例4: test_update_schedule

    def test_update_schedule(self):
        airship = ua.Airship('key', 'secret')
        sched = ua.ScheduledPush(airship)
        # Fail w/o URL
        self.assertRaises(ValueError, sched.update)

        with mock.patch.object(ua.Airship, '_request') as mock_request:
            url = "https://go.urbanairship.com/api/schedules/0492662a-1b52-4343-a1f9-c6b0c72931c0"

            response = requests.Response()
            response.status_code = 202
            response._content = (
                '''{"schedule_urls": ["https://go.urbanairship.com/api/schedules/0492662a-1b52-4343-a1f9-c6b0c72931c0"]}''')

            mock_request.return_value = response

            sched.url = url
            push = airship.create_push()
            push.audience = ua.all_
            push.notification = ua.notification(alert='Hello')
            push.device_types = ua.all_
            sched.push = push
            sched.schedule = ua.scheduled_time(datetime.datetime.now())

            sched.update()
开发者ID:KineticHub,项目名称:python-library,代码行数:25,代码来源:test_push.py


示例5: create_notification

def create_notification(receiver, reporter, content_object, notification_type):
    # If the receiver of this notification is the same as the reporter or
    # if the user has blocked this type, then don't create
    if receiver == reporter or not NotificationSetting.objects.get(notification_type=notification_type, user=receiver).allow:
        return

    notification = Notification.objects.create(user=receiver,
                                               reporter=reporter,
                                               content_object=content_object,
                                               notification_type=notification_type)
    notification.save()

    if AirshipToken.objects.filter(user=receiver, expired=False).exists():
        try:
            device_tokens = list(AirshipToken.objects.filter(user=receiver, expired=False).values_list('token', flat=True))
            airship = urbanairship.Airship(settings.AIRSHIP_APP_KEY, settings.AIRSHIP_APP_MASTER_SECRET)

            for device_token in device_tokens:
                push = airship.create_push()
                push.audience = urbanairship.device_token(device_token)
                push.notification = urbanairship.notification(ios=urbanairship.ios(alert=notification.push_message(), badge='+1'))
                push.device_types = urbanairship.device_types('ios')
                push.send()
        except urbanairship.AirshipFailure:
            pass
开发者ID:tashiro-wni,项目名称:manticore-tastypie-social,代码行数:25,代码来源:models.py


示例6: test_sms_overrides

    def test_sms_overrides(self):
        p = ua.Push(None)
        p.audience = ua.all_
        p.notification = ua.notification(
            alert='top level alert',
            sms=ua.sms(
                alert='sms override alert',
                expiry='2018-04-01T12:00:00',
            )
        )
        p.device_types = ua.device_types('sms')

        self.assertEqual(
            p.payload,
            {
                'audience': 'all',
                'device_types': ['sms'],
                'notification': {
                    'alert': 'top level alert',
                    'sms': {
                        'alert': 'sms override alert',
                        'expiry': '2018-04-01T12:00:00'
                    }
                }
            }
        )
开发者ID:urbanairship,项目名称:python-library,代码行数:26,代码来源:test_push.py


示例7: test_full_scheduled_payload

    def test_full_scheduled_payload(self):
        p = ua.Push(None)
        p.audience = ua.all_
        p.notification = ua.notification(alert='Hello')
        p.options = {}
        p.device_types = ua.all_
        p.message = ua.message("Title", "Body", "text/html", "utf8")
        sched = ua.ScheduledPush(None)
        sched.push = p
        sched.name = "a schedule"
        sched.schedule = ua.scheduled_time(
            datetime.datetime(2014, 1, 1, 12, 0, 0))

        self.assertEqual(sched.payload, {
            "name": "a schedule",
            "schedule": {'scheduled_time': '2014-01-01T12:00:00'},
            "push": {
                "audience": "all",
                "notification": {"alert": "Hello"},
                "device_types": "all",
                "options": {},
                "message": {
                    "title": "Title",
                    "body": "Body",
                    "content_type": "text/html",
                    "content_encoding": "utf8",
                },
            }
        })
开发者ID:KineticHub,项目名称:python-library,代码行数:29,代码来源:test_push.py


示例8: test_web_push

    def test_web_push(self):
        p = ua.Push(None)
        p.audience = ua.all_
        p.notification = ua.notification(
            alert='Hello',
            web={
                'title': 'This is a title.',
                'icon': {'url': 'https://example.com/icon.png'},
                'extra': {'attribute': 'id'},
                'time_to_live': 12345,
                'require_interaction': False
            }
        )
        p.device_types = 'web'

        self.assertEqual(
            p.payload,
            {
                'audience': 'all',
                'device_types': 'web',
                'notification': {
                    'alert': 'Hello',
                    'web': {
                        'title': 'This is a title.',
                        'icon': {'url': 'https://example.com/icon.png'},
                        'extra': {'attribute': 'id'},
                        'time_to_live': 12345,
                        'require_interaction': False
                    },
                }
            }
        )
开发者ID:urbanairship,项目名称:python-library,代码行数:32,代码来源:test_push.py


示例9: options

 def options(self):
     airship = ua.Airship('key', 'secret')
     push = ua.Push(None)
     push.audience = ua.all_
     push.notification = ua.notification(alert='Hello Expiry')
     push.options = ua.options(expiry='2013-04-01T18:45:0')
     push.device_types = ua.all_
开发者ID:afresh1,项目名称:python-library,代码行数:7,代码来源:test_message.py


示例10: push

    def push(self, notification):

        if not config.get(config.SERVICES_ENABLED, 'off') == 'on':
            logger.info('notifications disabled: %s marked as pending' % notification.id)
            return

        push = self.airship.create_push()
        push.audience = self.make_tags(notification.tags)
        push.notification = ua.notification(ios=ua.ios(alert=notification.message, extra=notification.payload))
        push.device_types = ua.device_types('ios')

        if notification.scheduled_for:

            schedule = self.airship.create_scheduled_push()
            schedule.push = push
            schedule.name = notification.type

            if notification.scheduled_for_local:
                schedule.schedule = local_scheduled_time(notification.scheduled_for)
            else:
                schedule.schedule = ua.scheduled_time(notification.scheduled_for)

            logger.info("Sending scheduled push to Urban Airship")
            resp = schedule.send()

        else:
            logger.info("Sending push to Urban Airship")
            resp = push.send()

        notification.meta['ua_response'] = resp.payload
        notification.sent = True
开发者ID:jcarbaugh,项目名称:norrin,代码行数:31,代码来源:adapters.py


示例11: test_standard_ios_opts

    def test_standard_ios_opts(self):
        p = ua.Push(None)
        p.audience = ua.all_
        p.notification = ua.notification(
            alert='Top level alert',
            ios=ua.ios(
                alert='iOS override alert',
                sound='cat.caf',
            )
        )
        p.device_types = ua.device_types('ios')

        self.assertEqual(
            p.payload,
            {
                'audience': 'all',
                'device_types': ['ios'],
                'notification': {
                    'alert': 'Top level alert',
                    'ios': {
                        'alert': 'iOS override alert',
                        'sound': 'cat.caf'
                    }
                }
            }
        )
开发者ID:urbanairship,项目名称:python-library,代码行数:26,代码来源:test_push.py


示例12: test_email_overrides

    def test_email_overrides(self):
        p = ua.Push(None)
        p.audience = ua.all_
        p.notification = ua.notification(
            email=ua.email(
                message_type='transactional',
                plaintext_body='hello',
                reply_to='[email protected]',
                sender_address='[email protected]',
                sender_name='test_name',
                subject='hi',
                html_body='<html>so rich!</html>'
            )
        )
        p.device_types = ua.device_types('email')

        self.assertEqual(
            p.payload,
            {
                'audience': 'all',
                'device_types': ['email'],
                'notification': {
                    'email': {
                        'message_type': 'transactional',
                        'plaintext_body': 'hello',
                        'reply_to': '[email protected]',
                        'sender_address': '[email protected]',
                        'sender_name': 'test_name',
                        'subject': 'hi',
                        'html_body': '<html>so rich!</html>'
                    }
                }
            }
        )
开发者ID:urbanairship,项目名称:python-library,代码行数:34,代码来源:test_push.py


示例13: test_local_schedule_success

    def test_local_schedule_success(self):
        with mock.patch.object(ua.Airship, '_request') as mock_request:
            response = requests.Response()
            response._content = json.dumps(
                {
                    'schedule_urls': [
                        (
                            'https://go.urbanairship.com/api/schedules/'
                            '0492662a-1b52-4343-a1f9-c6b0c72931c0'
                        )
                    ]
                }
            ).encode('utf-8')
            response.status_code = 202
            mock_request.return_value = response

            airship = ua.Airship('key', 'secret')
            sched = ua.ScheduledPush(airship)
            push = airship.create_push()
            push.audience = ua.all_
            push.notification = ua.notification(alert='Hello')
            push.device_types = ua.all_
            sched.push = push
            sched.schedule = ua.local_scheduled_time(datetime.datetime.now())
            sched.send()

            self.assertEquals(
                sched.url,
                (
                    'https://go.urbanairship.com/api/schedules/'
                    '0492662a-1b52-4343-a1f9-c6b0c72931c0'
                )
            )
开发者ID:afresh1,项目名称:python-library,代码行数:33,代码来源:test_push.py


示例14: send_push_notification

def send_push_notification():
    push = airship.create_push()
    push.audience = ua.all_
    push.notification = ua.notification(
        alert="Betimlenecek bir gorsel var",
        ios=ios(sound='betim', badge=1),
    )
    push.device_types = ua.all_
    push.send()
开发者ID:betim-app,项目名称:betim,代码行数:9,代码来源:app.py


示例15: test_simple_alert

 def test_simple_alert(self):
     self.assertEqual(
         ua.notification(
             alert='Hello'
         ),
         {
             'alert': 'Hello'
         }
     )
开发者ID:afresh1,项目名称:python-library,代码行数:9,代码来源:test_message.py


示例16: push_message_for_user

	def push_message_for_user(self, message, user, status):
		#self.airship.push({'aps': {'alert': message, 'badge':1, 'sound': 'default'},
		# 'status':status}, aliases=[user.username])

		push = self.airship.create_push()
		push.audience = ua.or_(ua.alias(user.username))
		push.notification = ua.notification(alert=message)
		push.device_types = ua.device_types('ios', 'android')
		push.send()
开发者ID:KineticHub,项目名称:DrinkUp-Server,代码行数:9,代码来源:AirshipHelper.py


示例17: test_email_missing_override

    def test_email_missing_override(self):
        p = ua.Push(None)
        p.audience = ua.all_
        p.notification = ua.notification(
            alert='no email to be found!'
        )
        p.device_types = ua.device_types('email')

        with self.assertRaises(ValueError):
            p.send()
开发者ID:urbanairship,项目名称:python-library,代码行数:10,代码来源:test_push.py


示例18: test_email_send

 def test_email_send(self):
     cas = ua.CreateAndSendPush(
         airship=self.airship,
         channels=self.test_email_objs
     )
     cas.notification = ua.notification(
         email=ua.email(
             message_type='commercial',
             plaintext_body='this is an email',
             reply_to='[email protected]',
             sender_address='[email protected]',
             sender_name='test sender',
             subject='this is an email'
         )
     )
     cas.device_types = ua.device_types('email')
     cas.campaigns = ua.campaigns(
         categories=['email', 'fun']
     )
     self.assertEqual(
         cas.payload,
         {
             'audience': {
                 'create_and_send': [
                     {
                         'ua_address': '[email protected]',
                         'ua_commercial_opted_in': '2018-02-13T11:58:59'
                     },
                     {
                         'ua_address': '[email protected]',
                         'ua_commercial_opted_in': '2018-02-13T11:58:59'
                     },
                     {
                         'ua_address': '[email protected]',
                         'ua_commercial_opted_in': '2018-02-13T11:58:59'
                     }
                 ]
             },
             'device_types': ['email'],
             'notification': {
                 'email': {
                     'subject': 'this is an email',
                     'plaintext_body': 'this is an email',
                     'message_type': 'commercial',
                     'sender_name': 'test sender',
                     'sender_address': '[email protected]',
                     'reply_to': '[email protected]'
                 }
             },
             'campaigns': {
                 'categories': ['email', 'fun']
             }
         }
     )
开发者ID:urbanairship,项目名称:python-library,代码行数:54,代码来源:test_create_and_send.py


示例19: test_ios

    def test_ios(self):
        self.assertEqual(
            ua.notification(ios=ua.ios(
                alert='Hello',
                badge='+1',
                sound='cat.caf',
                extra={'more': 'stuff'}
            )),
            {'ios': {
                'alert': 'Hello',
                'badge': '+1',
                'sound': 'cat.caf',
                'extra': {
                    'more': 'stuff',
                }
            }})

        self.assertEqual(
            ua.notification(ios=ua.ios(content_available=True)),
            {'ios': { 'content-available': True}})
开发者ID:05bit,项目名称:python-urbanairship3,代码行数:20,代码来源:test_message.py


示例20: test_scheduled_send

 def test_scheduled_send(self):
     cas = ua.CreateAndSendPush(
         airship=self.airship,
         channels=self.test_sms_objs
     )
     cas.notification = ua.notification(
         alert='test sms'
     )
     cas.device_types = ua.device_types('sms')
     cas.campaigns = ua.campaigns(
         categories=['sms', 'offers']
     )
     schedule = ua.ScheduledPush(airship=self.airship)
     schedule.name = 'test schedule name'
     schedule.push = cas
     schedule.schedule = ua.scheduled_time(
         datetime.datetime(2025, 10, 8, 12, 15)
         )
     self.assertEqual(
         schedule.payload,
         {
             'schedule': {
                 'scheduled_time': '2025-10-08T12:15:00'
             },
             'name': 'test schedule name',
             'push': {
                 'audience': {
                     'create_and_send': [
                         {
                             'ua_msisdn': '15035556789',
                             'ua_sender': '12345',
                             'ua_opted_in': '2018-02-13T11:58:59'
                         },
                         {
                             'ua_msisdn': '15035556788',
                             'ua_sender': '12345',
                             'ua_opted_in': '2018-02-13T11:58:59'
                         },
                         {
                             'ua_msisdn': '15035556787',
                             'ua_sender': '12345',
                             'ua_opted_in': '2018-02-13T11:58:59'
                         },
                     ]
                 },
                 'notification': {'alert': 'test sms'},
                 'device_types': ['sms'],
                 'campaigns': {
                     'categories': ['sms', 'offers']
                 }
             }
         }
     )
开发者ID:urbanairship,项目名称:python-library,代码行数:53,代码来源:test_create_and_send.py



注:本文中的urbanairship.notification函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python dataset.Dataset类代码示例发布时间:2022-05-27
下一篇:
Python uptime.uptime函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap