标签: push-notification

获取推送通知的设备令牌

我正在处理推送通知.我编写了以下代码来获取设备令牌.

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {    
    // Override point for customization after application launch.

    // Add the view controller's view to the window and display.
    [self.window addSubview:viewController.view];
    [self.window makeKeyAndVisible];

    NSLog(@"Registering for push notifications...");    
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:
     (UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert)];

    return YES;
}

- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken { 
    NSString *str = [NSString stringWithFormat:@"Device Token=%@",deviceToken];
    NSLog(@"This is device token%@", deviceToken);
}

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)err { 
    NSString *str = [NSString stringWithFormat: @"Error: %@", err];
    NSLog(@"Error %@",err);    
}
Run Code Online (Sandbox Code Playgroud)

我能够在设备上成功运行应用程序,但无法在控制台上获取设备ID.

我对认证和配置文件没有任何问题.

iphone push-notification apple-push-notifications ios appdelegate

73
推荐指数
7
解决办法
17万
查看次数

Android推送通知(GCM),有任何每日限制吗?

是否可以将数字推送通知(GCM)的每日限制发送给特定的Android应用程序用户?

android limit push-notification google-cloud-messaging

73
推荐指数
4
解决办法
9万
查看次数

为什么我从GCM服务器端获得"MismatchSenderId"?

我正在尝试为我的Android应用创建推送服务,并且我遵循Google GCM的文档和示例:

我可以注册/取消注册我的Android应用程序.从我的服务器端,我可以看到我注册了一个订阅,但当我尝试从服务器向我的Android应用程序发送消息时,我总是会收到以下错误:

向设备#0发送消息时出错:MismatchSenderId

对于我的Android应用,我使用SENDER_ID = 200000000001.

对于我的服务器端,谷歌说我使用API​​_KEY = AIzxxxxxxxxxxxxxxxxXxxXxxXxxxXXXXXxxxxs

我按照这个文件:

http://developer.android.com/guide/google/gcm/demo.html

我也在我的Google API面板中启用了GCM,但我会收到恼人的错误消息.

我该如何解决这个问题?

android push-notification google-cloud-messaging

71
推荐指数
3
解决办法
13万
查看次数

为什么推送通知不适用于testflight?

我已将测试推送通知作为开发人员帐户进行测试,但是当我尝试将其放在TestFlight上供测试人员测试时,它没有显示推送通知但是数据被正确接收,所以有一种我需要为TestFlight生成的证书?

push-notification apple-push-notifications ios testflight

71
推荐指数
5
解决办法
5万
查看次数

必须仅从主线程调用UIApplication.registerForRemoteNotifications()

Xcode 9(iOS 11)在注册Push(远程)通知时向我显示错误/警告.

这是错误消息

在此输入图像描述

这是代码,我尝试过:

let center  = UNUserNotificationCenter.current()
center.delegate = self
center.requestAuthorization(options: [.sound, .alert, .badge]) { (granted, error) in
        if error == nil{
              UIApplication.shared.registerForRemoteNotifications()
        }
 }
Run Code Online (Sandbox Code Playgroud)

错误/警告线:

UIApplication.shared.registerForRemoteNotifications()

怎么解决这个?

push-notification ios swift unusernotificationcenter swift4

71
推荐指数
5
解决办法
3万
查看次数

现在使用的是不推荐使用FirebaseInstanceId.getInstance().getToken()

我想知道在不推荐使用getToken()的情况下,获取Firebase令牌以发送推送通知的正确方法是什么.

android push-notification firebase firebase-cloud-messaging

65
推荐指数
2
解决办法
5万
查看次数

xcode 8推送通知功能和权利文件设置

使用时xcode 8做推送通知设置,不像xcode 7,xcode 8需要推送通知功能切换开发商转(位于TARGETS -> AppName -> Capabilities如下图), 推送通知功能

然后它将生成AppName.entitlements文件,如下所示

//AppName.entitlements
<key>aps-environment</key>
<string>development</string>
Run Code Online (Sandbox Code Playgroud)

但对于生产版App,如果我们将字符串更改为

//AppName.entitlements
<key>aps-environment</key>
<string>production</string>
Run Code Online (Sandbox Code Playgroud)

然后功能显示警告

能力警告

似乎无论在aps-environment中指定了哪个字符串值,我们仍然可以获得推送设备令牌 application:didRegisterForRemoteNotificationsWithDeviceToken:

那么推送通知权利的正确设置是什么?谢谢

push-notification ios10 xcode8 unnotificationrequest xcode8-beta6

64
推荐指数
1
解决办法
3万
查看次数

从android中的firebase发送通知时没有通知声音

我正在从firebase向我的Android应用程序发送推送通知.但是当我的应用程序处于后台时,不会调用firebase onMessageReceived方法而是调用firebase向系统发送通知,以便在系统托盘中显示通知.通知出现在系统托盘中但没有通知声音,即使我已在系统设置中允许我的应用程序发出通知声音.

当从firebase收到通知时,我可以做什么来播放通知声音.

这就是我从firebase向我的应用Blogpost链接发送通知的方式.

如何在Android应用程序中添加firebase

notifications android push-notification firebase firebase-cloud-messaging

63
推荐指数
7
解决办法
8万
查看次数

通过封闭的网络应用在Chrome或Firefox中发送桌面通知?

我的目标是通过浏览器中当前未打开的Web应用程序(我们称之为X)在Chrome或Firefox中发送Gmail样式的桌面通知,而无需用户安装应用程序或扩展程序.如果用户需要授予从X接收通知的权限,这是可以的,只要浏览器需要打开才能显示通知,只要X不需要在浏览器中打开就可以了.不需要打开任何浏览器窗口的解决方案也可以使用.

我只是花了一天时间深入研究这个问题,到目前为止我认为我已经学会了:

  • 自OSX Mavericks以来,已经可以通过Safari推送通知在Safari 7+中执行此操作.
  • 网站通知API工作在Chrome/Firefox中,但需要用户的浏览器开放给X.
  • Twitter发送类似的网络通知而不首先要求用户获得许可,但要求用户的浏览器对Twitter开放.
  • 有很多可能的Growl实现的引用,但据我所知,所有这些都需要用户安装Growl和/或支持Growl的应用程序才能工作.

我上面的任何陈述都错了 - 我很乐意听到它! - 我也对任何其他解决方案持开放态度.有任何想法吗?

谢谢阅读.

firefox notifications google-chrome push-notification web-notifications

59
推荐指数
1
解决办法
5万
查看次数

如何在Xamarin表单中使用推送通知

我有一个使用Xamarin.Forms的应用程序,目标是IOS,Android和WP 8.

我的应用程序中需要推送通知功能.

我看过pushsharp演示,看起来很有希望.但我见过的所有代码都是针对每个平台单独完成的.

我希望它可以在App.cs中的某个Xamarin.Forms项目中完成,这样我就不需要重复注册设备的代码,并处理如何处理推送通知.

任何帮助将不胜感激.欢迎提供示例代码或教程参考.

编辑:我是根据Idot的回答实现的.这是我的答案的链接.

c# push-notification xamarin pushsharp xamarin.forms

55
推荐指数
2
解决办法
6万
查看次数