我在iTunes商店有两个应用程序 - 都实现推送通知.当我测试向这些制作应用发送通知时,我注意到针对应用A的推送标题并打开了应用B.
这两个应用程序都安装在同一部手机上.我查看了我的设备表,看到为两个应用程序列出的设备令牌(当然,设备ID)都是相同的.
根据需要,我在服务器上使用两个不同的证书 - 每个应用程序一个.我有点假设设备令牌或证书会将消息路由到正确的应用程序但显然不是.
我可以在NSLog中看到从每个应用程序发送的令牌确实是相同的.
设备令牌应该对每个应用程序都是唯一的吗?如果是这样,任何想法我的测试手机如何将两个应用程序的相同设备令牌发送到我的服务器.请注意,这是来自应用商店目前的两个应用.
谢谢你的帮助!
这是Parse控制台上我的安装页面中的情况:
如您所见,某些设备具有"deviceToken",而某些设备没有"deviceToken".这并不好,因为每个设备都应该有deviceToken才能工作.
这怎么可能?这是一个严重的问题,因为那些没有deviceToken的人不会收到推送通知!
我已经按照Parse.com上的所有说明进行操作,即使在他们的空白项目的帮助下,也可以在网络上的各种问题的帮助下实现他们所说的一切.但没有解决我的问题,现在我无能为力.
我唯一能想到的是,在我的应用程序(它已经在商店中)之前用于使用Google Cloud Messaging,然后使用这个新的更新,我决定更改系统并使用Parse删除完全GCM系统.这两个系统之间是否存在冲突?
我需要解决这个问题,因为你可以想象这是一个严重的错误,现在我的3/4用户都没有收到推送通知.
如果你下载应用程序并安装它:一切都很好,deviceToken是好的.如果您更新应用程序,因为设备上已存在GCM版本:
对于没有deviceToken的设备,我尝试了很多东西:手动插入deviceToken,卸载并重新安装应用程序,删除Parse上的特定行等.但没什么好...仍然面临这个问题.
我的代码
Application.java
public class Application extends android.app.Application {
public Application() {
}
@Override
public void onCreate() {
super.onCreate();
// Initialize the Parse SDK.
Parse.initialize(this, "x", "x");
// Specify an Activity to handle all pushes by default.
PushService.setDefaultPushCallback(this, MainActivity.class);
}
Run Code Online (Sandbox Code Playgroud)
}
MainActivity.java 在我的mainActivity中,我只是将deviceToken(在我的情况下是installId)连接到我的userAgent:这工作正常:我总是有installId没有任何问题!这是我在MainActivity中唯一做的事情(我还需要做其他事吗?saveInBackground,callback等......?)
deviceToken = ParseInstallation.getCurrentInstallation().getInstallationId();
webSettings.setUserAgentString(userAgent + " ||" + deviceToken);
Run Code Online (Sandbox Code Playgroud)
AndroidManifest.xml中
<!-- Gestione del guasto-->
<uses-permission android:name="android.permission.CAMERA" />
<uses-permission …
Run Code Online (Sandbox Code Playgroud) android push-notification devicetoken parse-platform google-cloud-messaging
我正在开发一个需要推送通知的iPhone应用程序.我按照说明创建了认证并修改了应用ID.我并不完全确定我这样做是正确的,但我的确遵循了指示.知道如何检查这是否正常?
当我在模拟器中运行时,我收到一条错误消息,指出模拟器不支持推送通知.这有点预期.
顺便说一下:我有几次看似这个问题.它总是似乎是一个破牢的手机.我的手机没有被囚禁.
但是当我在iPhone上调试时,didRegisterForRemoteNotificationsWithDeviceToken方法永远不会被触发.我真的很感激一些帮助.我的代码如下.
-(void)applicationDidFinishLaunching:(UIApplication *)application
{
rootController.delegate = self;
[window addSubview:rootController.view];
[window makeKeyAndVisible];
[[UIApplication sharedApplication]
registerForRemoteNotificationTypes:
(UIRemoteNotificationTypeAlert |
UIRemoteNotificationTypeBadge |
UIRemoteNotificationTypeSound)];
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken
{
NSString *str =
[NSString stringWithFormat:@"%@",deviceToken];
NSLog(str);
}
- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err
{
NSString *str = [NSString stringWithFormat: @"Error: %@", err];
NSLog(str);
}
Run Code Online (Sandbox Code Playgroud) 我在一台设备上有两个应用程序.对于iOS 7,两个应用程序都发送不同的设备令牌,但对于iOS 6,这两个应用程序都发送相同的设备令牌.
根据我的理解,设备令牌必须与一个设备中的所有应用程序相同.iOS7与iOS 6有什么不同吗?
每个人都在我的应用程序中使用解析服务进行推送通知.但是当我在一台设备上重新安装应用程序时,它会一直注册.然后问题是,一台设备会在每台设备上收到多个通知.我已经完成了一些注册代码,如下所示.请帮助我,提前谢谢.
Parse.initialize(this, PARSE_APP_ID, PARSE_CLIENT_KEY);
ParseACL defaultACL = new ParseACL();
defaultACL.setPublicReadAccess(true);
ParseACL.setDefaultACL(defaultACL, true);
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseInstallation.getCurrentInstallation().getInstallationId();
ParseInstallation.getCurrentInstallation().saveInBackground();
Run Code Online (Sandbox Code Playgroud)
并订阅:
PushService.subscribe(this, userName, Detail.class);
Run Code Online (Sandbox Code Playgroud)
在清单中
以上
<permission
android:name="com.example.app.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="com.example.app.permission.C2D_MESSAGE" />
Run Code Online (Sandbox Code Playgroud)
在应用标签中:
<receiver android:name="com.parse.ParseBroadcastReceiver" >
<intent-filter>
<action android:name="android.intent.action.BOOT_COMPLETED" />
<action android:name="android.intent.action.USER_PRESENT" />
<action android:name="act" />
</intent-filter>
</receiver>
<receiver android:name="com.app.example.PushReceiver" >
<intent-filter>
<action android:name="act" />
</action>
</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" />
<action android:name="act" />
<category android:name="com.example.app" />
</intent-filter>
</receiver>
Run Code Online (Sandbox Code Playgroud)
每次我安装时,都显示错误,如下所示.
03-10 12:18:48.555: E/ParseCommandCache(12709): Failed to …
Run Code Online (Sandbox Code Playgroud) android push-notification devicetoken parse-platform google-cloud-messaging
在我的iPhone应用程序中,我从Apple获取设备令牌,我在Delegate文件中分配了一个公共属性,如下所示:
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
self.dToken = [[NSString alloc] initWithData:deviceToken encoding:NSUTF8StringEncoding];
}
Run Code Online (Sandbox Code Playgroud)
dToken属性声明如下:
NSString *dToken;
@property (nonatomic,retain) NSString *dToken;
Run Code Online (Sandbox Code Playgroud)
但是当我尝试从另一个文件中检索设备令牌时,我得到了null值.
+(NSString *) getDeviceToken
{
NSString *deviceToken = [(MyAppDelegate *)[[UIApplication sharedApplication] delegate] dToken];
NSLog(@" getDeviceToken = %@",deviceToken); // This prints NULL
return deviceToken;
}
Run Code Online (Sandbox Code Playgroud)
我究竟做错了什么?
我需要获取设备令牌,因为我将它用于自动登录.但是,如果用户在他/她的设备中不允许来自我的应用程序的推送通知,我将无法获得设备令牌.我想知道即使他/她没有启用APN,是否可以获取并存储用户的设备令牌.谢谢.
我已经阅读了很多这方面的教程,我只是想知道这是否是正确的方法
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
NSLog(@"My token is: %@", deviceToken);
NSString* newToken = [deviceToken description];
newToken = [newToken stringByTrimmingCharactersInSet:[NSCharacterSet characterSetWithCharactersInString:@"<>"]];
newToken = [newToken stringByReplacingOccurrencesOfString:@" " withString:@""];
NSString *urlString = [NSString stringWithFormat:@"http://myhost.com./filecreate.php?token=%@",newToken];
NSURL *url = [[NSURL alloc] initWithString:urlString];
NSURLRequest *urlRequest = [NSURLRequest requestWithURL:url];
NSData *urlData;
NSURLResponse *response;
urlData = [NSURLConnection sendSynchronousRequest:urlRequest returningResponse:&response error:nil];
}
Run Code Online (Sandbox Code Playgroud)
任何建议都受到欢迎.
- (void)application:(UIApplication*)application didRegisterForRemoteNotificationsWithDeviceToken:(NSData*)deviceToken
{
const char* data = [deviceToken bytes];
NSMutableString* token = [NSMutableString string];
for (int i = 0; i < [deviceToken length]; i++) { …
Run Code Online (Sandbox Code Playgroud)