- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我已按照以下所有说明在 Android 中为应用配置推送通知: https://github.com/ParsePlatform/Parse-Server/wiki/Push-Configuring-Clients https://parseplatform.github.io/docs/android/guide/#push-notifications
可是不管我怎么操作,我用的手机好像根本收不到任何推送通知。
相同的应用程序配置为在 iOS 上接收通知并且运行完美。
这些是 list 中的相关位:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.xxy.xxy">
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.WAKE_LOCK" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="com.google.android.c2dm.permission.RECEIVE" />
<uses-permission android:name="android.permission.GET_ACCOUNTS" />
<permission
android:name="com.xxy.xxy.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.xxy.xxy.permission.C2D_MESSAGE" />
<application
android:name="com.xxy.xxy.MiXXYApplication"
android:allowBackup="true"
android:icon="@drawable/logoapp"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<service android:name="com.parse.PushService" />
<receiver
android:name="com.parse.ParsePushBroadcastReceiver"
android:exported="false">
<intent-filter>
<action android:name="com.parse.push.intent.RECEIVE" />
<action android:name="com.parse.push.intent.DELETE" />
<action android:name="com.parse.push.intent.OPEN" />
</intent-filter>
</receiver>
<receiver
android:name="com.parse.GcmBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND">
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="com.xxy.xxy" />
</intent-filter>
</receiver>
<meta-data
android:name="com.parse.push.gcm_sender_id"
android:value="id:123456789012" />
</application>
这是 Application 类(AppID 和 Client Key 替换为 Back4App 给出的当前值):
public class MiXXYApplication extends Application {
@Override
public void onCreate() {
super.onCreate();
Parse.setLogLevel(Parse.LOG_LEVEL_VERBOSE);
Parse.initialize(new Parse.Configuration.Builder(getApplicationContext())
.applicationId("back4App_AppID")
.clientKey("back4App_ClientKey")
.server("https://parseapi.back4app.com/")
.build()
);
}
}
这些是我调用来注册安装的方法(我不能在 Application 类上这样做,因为我需要 userId,登录后)
public void enablePush(final String userId) {
ParseInstallation installation = ParseInstallation.getCurrentInstallation();
installation.put("GCMSenderId", "123456789012");
installation.put("userId", userId);
installation.saveInBackground(new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.i("push", "ok");
subscribe("");
subscribe(userId);
} else {
Log.i("push", "nok");
e.printStackTrace();
}
}
});
}
public void subscribe(String channel){
ParsePush.subscribeInBackground(channel, new SaveCallback() {
@Override
public void done(ParseException e) {
if (e == null) {
Log.i("Push", "subscribed");
} else {
Log.i("push", "nok");
e.printStackTrace();
}
}
});
}
这是 Parse DB 上的安装注册表:
ObjectID: l1tkO3YM2r
GCMSenderID: 123456789012
deviceToken: APA91bHeKnj...
localeIdentifier: en-US
badge: (undefined)
parseVersion: 1.13.1
ACL: Public Read + Write
appIdentifier: com.xxy.xxy
appName: appName
deviceType: android
channels: ["","CyTPw5xc4r"]
pushType: gcm
installationId: 8cf9c606-5a0e...
userId: CyTPw5xc4r
在谷歌开发者控制台中,项目编号是 123456789012,我创建了一个 API key 并在 Back4App 仪表板的 Android 推送通知设置中添加了 API key + 项目编号。
详细模式下的 logcat 显示如下:
09-21 09:29:19.863 10721-10721/com.xxy.xxy V/com.parse.ManifestInfo: Using gcm for push.
09-21 09:29:19.884 10721-10885/com.xxy.xxy V/com.parse.CachedCurrentInstallationController: Successfully deserialized Installation object
09-21 09:29:19.899 10721-10886/com.xxy.xxy V/com.parse.GcmRegistrar: Sending GCM registration intent
09-21 09:29:29.782 10721-11340/com.xxy.xxy V/com.parse.GcmRegistrar: Received deviceToken <APA91bHeKnj...> from GCM.
据我所知,一切顺利,但我的手机没有收到任何通知。
我的设置有问题吗?谢谢!
最佳答案
解决了!
问题是,您应该从https://developers.google.com/mobile/add 获取它,而不是像所有指南所说的那样获取Api key 。 .
它生成了另一个 API key 并激活了服务,然后,它就开始工作了。
关于未收到在 Back4App 上使用 Parse 的 Android 推送通知,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39610971/
有时,我倾向于(重复)执行next next a 来获取特定元素。当您需要 2 次或更少的遍历时,这很有效。然而,它很快就会变得很麻烦。对于这个简单的情况,循环的开销太大。 幸运的是,如果您知道位置,
我有一个非常复杂的表单,其中有多个“阶段”。 每个阶段都有表单,用户可以在其中添加不定数量的行。每次用户单击“继续”时,这些表单都会保存到数据库中(每个“阶段”在数据库中都有自己的表)并显示下一阶段。
我根据官方指南调整了我的网站 https://developer.apple.com/library/archive/documentation/AppleApplications/Reference
Action Bar 我说的是(图中的 1 号)带有小箭头的按钮和应用程序图标以及屏幕的左上角。当我们选择“黑色 Activity ”模板时,它会自动定义。 我的应用程序有一个非常庞大的层次结构图,现
我正在开发一个网站,我需要返回到我访问过的页面。我正在使用parent.history.back。我的一位 friend 建议使用 window.history.back 而不是 Parent.his
我正在寻找一种方法将所有后退按钮文本设置为“后退”,而不是默认显示 segue 来自的 View 的标题。 我有多个 View 和 segue,希望有比在所有 View Controller 中使用
我有一个名为 Place 的 Activity 我从其之前名为 City 的 Activity 来到 Place Activity 。 我使用以下代码在 Place Activity 中将后退按钮添加
这个问题已经有答案了: AlertDialog OnBackPressed() Not Working Properly (3 个回答) 已关闭 4 年前。 我想实现抽屉导航后按对话框上的对话框后按。
我为一家报纸开发了一个非常受欢迎的新闻应用程序。不幸的是,我的用户报告了我可以重现的以下问题: 该应用程序基本上由一个 GroupedItemsPage 和一个 ItemDetailPage (以及其
我一直想知道是否有正确的方法来执行此操作:当我使用 AJAX 动态加载脚本时,我可以选择将 url 传回服务器上的脚本,然后运行:或者只是传回脚本本身。 我采用了传回内容脚本本身的方法,因为我认为我只
我是用 Linux BASH shell 写的,但如果有更好的 PHP 解决方案就好了。 我需要从 12 个元素的数组中随机选择一个。这是我到目前为止一直在做的事情: # Display/return
据我所知,似乎插入 UINavigationController背靠背动画在 iOS7 上造成了死锁。 我最初在 iOS6 上遇到崩溃并想出了以下解决方案: 创建一个 View Controller
我目前正在为我的电子应用程序构建一个许可系统。但我在以下方面没有取得成功: promise 提示用户输入(电子提示模块) 之后立即对服务器进行 ajax 调用 评估响应(来自服务器端脚本的 1\n 或
我正在尝试为我在开发小型应用程序时遇到的一个小问题找出解决方案。我试图传递一个在一个支持 bean 中创建的对象,然后使用我在另一个支持 bean 中创建的同一对象。但是,我不想制作这些支持 bean
我有一个带有 Activity 的应用程序。在 Activity 中,我使用对话框 fragment 设置一些局部变量(这些变量确实有默认值)。我还有一个带有“三点”图标的操作栏,允许用户设置一些首选
我正在使用 React Navigation 3 升级我的 React Native 应用程序的路由器配置,现在已经改进了很多东西,但我不明白为什么当我在 Android 中按下后退按钮时,没有将我发
有没有办法通过 python 笔记本确定现有的 Azure Databricks Secret Scope 是否由 Key Vault 或 Databricks 支持? dbutils.secrets
我有一个基于 backbone.js 路由器的应用程序,它使用默认的 hashchange 处理程序在页面之间移动。在一个页面上有一个触发模态框的按钮,如果用户按下返回,我想关闭它,而不是将用户返回历
我试图了解层支持的 NSViews 是如何工作的。我在 playground 中创建了以下代码。 import Cocoa import XCPlayground class MyView: NSVi
我将鼠标悬停在导航栏中的一个链接上,它改变了颜色。 我在 Firefox 和 Safari 中遇到一个奇怪的问题:当我在浏览器中返回时(通过用鼠标单击后退按钮)悬停链接后,链接的颜色不会更改为其原始状
我是一名优秀的程序员,十分优秀!