def testMappingQueries(self): import emission.core.wrapper.user as ecwu self.test_email_1 = "test_push_1" self.test_email_2 = "test_push_2" try: user_1 = ecwu.User.register(self.test_email_1) user_2 = ecwu.User.register(self.test_email_2) user_1.update({ "curr_platform": "ios", "curr_sync_interval": 3600, "device_token": "ios_device_token" }) user_2.update({ "curr_platform": "android", "curr_sync_interval": 3600, "device_token": "android_device_token" }) uuid_token_list = pnq.get_matching_tokens( pnq.get_user_query([user_1.uuid, user_2.uuid])) self.assertEqual(uuid_token_list, ["ios_device_token", "android_device_token"]) platform_token_list = pnq.get_matching_tokens( pnq.get_platform_query("ios")) self.assertEqual(platform_token_list, ["ios_device_token"]) finally: ecwu.User.unregister(self.test_email_1) ecwu.User.unregister(self.test_email_2)
def send_silent_notification_to_ios_with_interval(interval, dev=False): query = pnq.combine_queries( [pnq.get_platform_query("ios"), pnq.get_sync_interval_query(interval)]) token_map = pnq.get_matching_tokens(query) logging.debug("found %d tokens for ios with interval %d" % (len(token_map), interval)) return __get_default_interface__().send_silent_notification( token_map, {}, dev)
def send_visible_notification_to_users(user_id_list, title, message, json_data, dev=False): token_map = pnq.get_matching_tokens(pnq.get_user_query(user_id_list)) logging.debug( "user_id_list of length %d -> token list of length %d" % (len(user_id_list), len(token_map["ios"]) + len(token_map["android"]))) return __get_default_interface__().send_visible_notification( token_map, title, message, json_data, dev)
def testMappingQueries(self): import emission.core.wrapper.user as ecwu self.test_email_1 = "test_push_1" self.test_email_2 = "test_push_2" try: user_1 = ecwu.User.register(self.test_email_1) user_2 = ecwu.User.register(self.test_email_2) user_1.update({"curr_platform": "ios", "curr_sync_interval": 3600, "device_token": "ios_device_token"}) user_2.update({"curr_platform": "android", "curr_sync_interval": 3600, "device_token": "android_device_token"}) uuid_token_list = pnq.get_matching_tokens(pnq.get_user_query([user_1.uuid, user_2.uuid])) self.assertEqual(uuid_token_list, ["ios_device_token", "android_device_token"]) platform_token_list = pnq.get_matching_tokens(pnq.get_platform_query("ios")) self.assertEqual(platform_token_list, ["ios_device_token"]) finally: ecwu.User.unregister(self.test_email_1) ecwu.User.unregister(self.test_email_2)
def send_silent_notification_to_ios_with_interval(interval, dev=False): query = pnq.combine_queries([pnq.get_platform_query("ios"), pnq.get_sync_interval_query(interval)]) token_map = pnq.get_matching_tokens(query) logging.debug("found %d tokens for ios with interval %d" % (len(token_map), interval)) return __get_default_interface__().send_silent_notification(token_map, {}, dev)
def send_silent_notification_to_users(user_id_list, json_data, dev=False): token_map = pnq.get_matching_tokens(pnq.get_user_query(user_id_list)) logging.debug("user_id_list of length %d -> token list of length %d" % (len(user_id_list), len(token_map))) return __get_default_interface__().send_silent_notification(token_map, json_data, dev)
def send_visible_notification_to_users(user_id_list, title, message, json_data, dev=False): token_map = pnq.get_matching_tokens(pnq.get_user_query(user_id_list)) logging.debug("user_id_list of length %d -> token list of length %d" % (len(user_id_list), len(token_map["ios"]) + len(token_map["android"]))) return __get_default_interface__().send_visible_notification(token_map, title, message, json_data, dev)
def send_silent_notification_to_users(user_id_list, json_data, dev=False): token_map = pnq.get_matching_tokens(pnq.get_user_query(user_id_list)) logging.debug("user_id_list of length %d -> token list of length %d" % (len(user_id_list), len(token_map))) return __get_default_interface__().send_silent_notification( token_map, json_data, dev)
def send_silent_notification_to_users(user_id_list, json_data, dev=False): token_list = pnq.get_matching_tokens(pnq.get_user_query(user_id_list)) logging.debug("user_id_list of length %d -> token list of length %d" % (len(user_id_list), len(token_list))) # assert(len(user_id_list) == len(token_list)) return pni.send_silent_notification(token_list, json_data, dev)