#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

import push_admin
import json
from push_admin import messaging

android = messaging.AndroidConfig(
    collapse_key=-1,
    urgency=messaging.AndroidConfig.HIGH_PRIORITY,
    ttl="10000s",
    bi_tag='the_sample_bi_tag_for_receipt_service',
    fast_app_target=1,
    category=None)


def send_push_android_data_message():
    """
    a sample to show hwo to send web push message
    :return:
    """
    message = messaging.Message(
        # English sample
        # data = "{\"pushtype\":0,\"pushbody\":{\"title\":\"Welcome to use Huawei HMS Push Kit?\",\"description\":\"One "
        #       + "of the best push platform on the planet!!!\",\"page\":\"/\",\"params\":{\"key1\":\"test1\",\"key2\":\"test2\"},\"ringtone\":"
        #       + "{\"vibration\":\"true\",\"breathLight\":\"true\"}}}",
Exemple #2
0
    group='Group1',
    importance=messaging.AndroidNotification.PRIORITY_HIGH,
    light_settings=messaging.AndroidLightSettings(
        color=messaging.AndroidLightSettingsColor(alpha=0,
                                                  red=0,
                                                  green=1,
                                                  blue=1),
        light_on_duration="3.5",
        light_off_duration="5S"),
    badge=messaging.AndroidBadgeNotification(add_num=1, clazz='Classic'),
    visibility=messaging.AndroidNotification.PUBLIC,
    foreground_show=True)

android = messaging.AndroidConfig(
    collapse_key=-1,
    urgency=messaging.AndroidConfig.HIGH_PRIORITY,
    ttl="10000s",
    bi_tag='the_sample_bi_tag_for_receipt_service',
    notification=android_notification)


def send_push_android_notify_message():
    """
    a sample to show hwo to send web push message
    :return:
    """
    message = messaging.Message(notification=notification,
                                android=android,
                                token=[push_env.test_device_token])

    try:
        response = messaging.send_message(message)