【问题标题】:Push Notification from Pusher/Beams won't show up in emulator来自 Pusher/Beams 的推送通知不会显示在模拟器中
【发布时间】:2018-11-27 19:27:05
【问题描述】:

我为我的 android 应用程序设置了 Pusher/Beams 帐户,但是当我执行脚本以发送通知时,它没有显示在运行我的应用程序的 android studios 模拟器上。 Android Studio 代码:

import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;

import com.pusher.pushnotifications.PushNotifications;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        PushNotifications.start(getApplicationContext(), "instance_id");
        PushNotifications.subscribe("hello");
    }
}

发送通知的 Python 脚本: 从 pusher_push_notifications 导入 PushNotifications

pn_client = PushNotifications(
    instance_id='INSTANCE_ID',
    secret_key='SECRET_KEY')

def notify(title, message, data):
    response = pn_client.publish(
      interests=['hello'],
      publish_body={
        'fcm': {
            'notification': {
                'title': title, 
                'body': message
                }}})

    print(response['publishId'])

【问题讨论】:

    标签: python android-studio push-notification pusher


    【解决方案1】:

    确保您的应用已最小化。您的发布负载仅适用于 UI,因此只有在您的应用最小化时才会显示在系统托盘中。

    【讨论】:

    • 好的,我看到它在顶部栏中显示为应用程序图标。但我需要它显示为提醒通知。无论如何可以通过Beams做到这一点。我找不到这方面的任何文档
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-07-20
    • 1970-01-01
    • 2021-05-08
    • 1970-01-01
    • 2014-03-11
    相关资源
    最近更新 更多