标签: push-notification

模拟器上的设备令牌请求没有响应

我是 iphone 技术的新手,现在我正在使用一个需要实现推送通知的应用程序。

我按照链接:

http://mobiforge.com/developing/story/programming-apple-push-notification-services#comment-7850

另外,使用了以下代码:

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

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

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

- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo 
{
    for (id key in userInfo) 
 {
        NSLog(@"key: %@, value: %@", key, [userInfo objectForKey:key]);
    }    
}
Run Code Online (Sandbox Code Playgroud)

事情是,当我运行程序时,我应该根据代码在调试器窗口中获取设备令牌,而不是我收到如下错误:

" 注册错误。错误:Error Domain=NSCocoaErrorDomain Code=3010 "模拟器不支持远程通知" UserInfo=0x6e055a0 {NSLocalizedDescription=模拟器不支持远程通知} "

我应该如何解决这个问题?

请帮帮我。 …

push-notification apple-push-notifications ios ios-simulator

0
推荐指数
1
解决办法
2万
查看次数

使用图像推送通知 - iOS - Swift

嗨,我只想用图像显示推送通知.我使用下面的代码,我不知道我在哪里做错了它花了我超过3周,我经历了很多链接但仍然无法修复.以下是我的App委托代码

AppDelegate.Swift

import UIKit
import UserNotifications

var deviceTokenString:String = ""
var badgeCount = 0

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate, UNUserNotificationCenterDelegate {

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    // Push Notification

    if #available(iOS 10.0, *)
    {
        let center = UNUserNotificationCenter.current()
        center.requestAuthorization(options: [.alert, .badge, .sound]) { (granted, error) in

            // actions based on whether notifications were authorised or not

            guard error == nil else {

                //Display Error.. Handle Error.. etc..

                return
            }

            if granted …
Run Code Online (Sandbox Code Playgroud)

image push-notification ios swift

0
推荐指数
1
解决办法
3150
查看次数

无法使用FCM在前台接收推送通知

我一直试图在我的应用程序中获取firebase推送通知.我已尝试过互联网上的所有内容但无法找到解决方案.我一直在后台收到通知,但是当App在前台时,我无法收到通知.但是当我在"didReceiveRemoteNotification"中打印userInfo时,我在控制台中收到消息.任何帮助都将不胜感激.

import Firebase
import UserNotifications


@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate{

var window: UIWindow?


func application(_ application: UIApplication, didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {

    //FirebaseApp.configure()

    self.initializeFCM(application)
    let token = InstanceID.instanceID().token()
    debugPrint("GCM TOKEN = \(String(describing: token))")

    return true
}

 func application(_ application: UIApplication, didFailToRegisterForRemoteNotificationsWithError error: Error)
{
    debugPrint("didFailToRegisterForRemoteNotificationsWithError: \(error)")
}

func application(received remoteMessage: MessagingRemoteMessage)
{
    debugPrint("remoteMessage:\(remoteMessage.appData)")
}

func initializeFCM(_ application: UIApplication)
{
    print("initializeFCM")

    if #available(iOS 10.0, *) // enable new way for notifications on iOS 10
    {
        let center = UNUserNotificationCenter.current() …
Run Code Online (Sandbox Code Playgroud)

push-notification ios firebase swift firebase-cloud-messaging

0
推荐指数
1
解决办法
5050
查看次数

使用 Xamarin 和 Azure 应用服务移动应用的 iOS/APNS 的 Azure 通知中心 InvalidToken 错误

我正在尝试将通知添加到我的 Azure 移动应用程序(Azure 应用程序服务移动应用程序),并且正在努力让它们与 iOS 一起使用。我已经成功地让他们为 Android 工作。

我已按照在线说明设置 Apple 证书和配置文件:

https://adrianhall.github.io/develop-mobile-apps-with-csharp-and-azure/chapter5/ios/

iOS 应用程序正在向 APNS 注册并收到设备令牌。然后我删除“<”和“>”字符以及空格,并将注册发送到通知中心。

 var templates = new JObject
 {
     ["genericMessage"] = new JObject
     {
         {"body", "{\"aps\":{\"alert\":\"$(message)\"}}"}
     }
 };

 var push = m_MobileServiceClient.GetPush();
 await push.RegisterAsync(token, templates);
Run Code Online (Sandbox Code Playgroud)

当我发送第一个推送通知请求时...

 var notification = new Dictionary<string, string> { { "message", "Test notification message" } };
 await m_Hub.SendTemplateNotificationAsync(notification);
Run Code Online (Sandbox Code Playgroud)

...注册已从通知中心删除。

我已将 Azure 通知中心上的定价层提高到标准,并使用它来查找存储在存储帐户中的跟踪,它显示“InvalidToken”作为来自 APNS 的错误。

我做过/检查过的事情:

  • 通知中心作为 APNS 凭据设置为开发证书(从 Apple 开发人员门户为启用推送通知的非通配符应用 ID 创建和导出)和沙盒环境。
  • iOS App 项目设置为使用开发者身份和 App ID 链接到的配置文件:

iOS 项目捆绑签名设置

  • 我在 Info.plist 中添加了以下内容(并非所有说明都包含此内容,但其他文章建议它是必需的)

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

push-notification xamarin.ios apple-push-notifications azure-mobile-services azure-notificationhub

0
推荐指数
1
解决办法
1005
查看次数

使用APNS发送远程推送通知的发送报告 - IOS

我正在使用APNS发送远程推送通知.要求是将通知发送给应用程序用户(即使用户没有点击通知或甚至看不到通知),根据通知ID i向Web服务器发送送达回执(即调用Web服务)接收.

APNS没有提供交付报告.他们是APNS的反馈服务,但也不提供交付报告.

所以我想知道获得远程推送通知的交付报告的可能方法是什么.如果我能够在APP deligate或其他任何其他远程推送通知到达时执行自定义方法,即使APP在后台或由用户终止,那么它将解决我的问题.

任何帮助将受到高度赞赏.

下面是我目前使用的代码,当应用程序处于后台时,它无法正常工作.

我写了一个自定义方法

-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
Run Code Online (Sandbox Code Playgroud)

向服务器发送确认收到通知的确认.当应用程序在前台时,所有功能都完美地执行.但是当应用程序处于后台时会出现问题.写的自定义方法

 -(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo
Run Code Online (Sandbox Code Playgroud)

直到用户通过点击通知栏打开应用程序才执行,如果用户通过点击应用程序图标而不是通知栏打开应用程序,则不会执行.

iphone objective-c push-notification apple-push-notifications ios

0
推荐指数
1
解决办法
2061
查看次数

iOS FCM 推送通知在后台状态下无法快速工作?

在我的应用程序中,我实现了 FCM 推送通知。当使用 FCM 控制台和 pushtry.com 网站检查通知时,它工作正常,然后我尝试使用实际的服务器 API,前台通知运行良好,但后台通知未收到,有时它很少收到,而且没有横幅和声音。请帮助找出问题。

在这里,我附上了我正在尝试的代码。

import UIKit
import UserNotifications
import Firebase

@UIApplicationMain
class AppDelegate: UIResponder, UIApplicationDelegate {

var window: UIWindow?

func application(_ application: UIApplication,
             didFinishLaunchingWithOptions launchOptions: [UIApplicationLaunchOptionsKey: Any]?) -> Bool {
FirebaseApp.configure()

Messaging.messaging().delegate = self
if #available(iOS 10.0, *) {
    UNUserNotificationCenter.current().delegate = self

    let authOptions: UNAuthorizationOptions = [.alert, .badge, .sound]
    UNUserNotificationCenter.current().requestAuthorization(
        options: authOptions,
        completionHandler: {_, _ in })
} else {
    let settings: UIUserNotificationSettings =
        UIUserNotificationSettings(types: [.alert, .badge, .sound], categories: nil)
    application.registerUserNotificationSettings(settings)
}

application.registerForRemoteNotifications()
return true …
Run Code Online (Sandbox Code Playgroud)

push-notification ios firebase swift firebase-cloud-messaging

0
推荐指数
1
解决办法
4531
查看次数

Python - 在MySQL数据库发生变化后向Android应用程序发送通知

我正在pythonanywhere.com上开展项目,我的Python代码(使用Flask框架)管理想要访问MySQL数据库的Android应用程序的请求.

重点是,当一行添加到数据库表时,我希望通知Android智能手机.

如果我理解正确,从Python到Android我可以使用Firebase云消息传递,但我不确定从MySQL到Python使用什么:触发器调用将发送通知的脚本?还是Python听数据库?还有什么?

请记住,我没有使用个人服务器和数据库,而是使用上述域名提供的服务器和数据库,因此我不确定我是否可以使用我想要的所有内容(例如,如果我没有弄错,就不可能恳求UDF ).

提前致谢!

python mysql android push-notification firebase

0
推荐指数
1
解决办法
389
查看次数

强制退出应用程序在后台模式下的静音通知

我的问题是:当用户强制退出(滑动)应用程序时,我无法使无提示通知工作!

我想以下是一个事实:如果应用程序被用户强制退出(刷掉),静默推送(使用content-available:1)不会触发,application(_:didReceiveRemoteNotification:fetchCompletionHandler:)也不会触发任何其他方法(它不会启动应用程序)!谁能证明这是错误的?

我已确保已启用Background Mode: Remote Notifications

但是如果非静音通知对我不起作用怎么办?我需要静默的,我需要在展示之前能够运行一些检查!如果我想在收到来自远程服务器的通知后检查是否有正确的用户登录到我的应用程序,该怎么办?(因为我不能保证当他退出时他成功地让服务器知道,所以我假设服务器不确定)

在我的情况下采取什么正确的方法?

类似的事情有很多问题,但涉及的人并不多,不知道为什么?我不相信我有这么罕见的情况。也许我解决这类问题的基本方法是错误的?在Android平台上似乎完全没有问题!

我使用 FCM 作为发送通知的中心点,所以如果你说 PushKit 可以解决我的问题,FCM 不支持 VoIP 证书太糟糕了。但是,我想知道,PushKit 真的能解决这个问题吗?或者苹果只是这样设计的,当用户强制退出一个应用程序时,这意味着这个应用程序必须完全关闭才能推送远程通知?!

我不认为这是Firebase 静默通知的副本不会启动关闭的 iOS 应用程序,因为我在这里问的是如果您想检查通知所针对的用户是否对应于用户登录到应用程序?如果事实证明在 iOS 平台上绝对没有解决方案,则可以认为是重复的。

push-notification apple-push-notifications uiapplicationdelegate ios swift

0
推荐指数
1
解决办法
1097
查看次数

有没有办法在android上使用开放的街道地图生成地理围栏?

我想创建一个简单的地图应用程序,当设备的地理位置进入地理围栏时发送推送通知。我一直在寻找一种在 osmdroid 上显示地理围栏的方法。我一直看到的是谷歌地图的例子。但是,我没有使用谷歌地图。我是否仍然需要使用 Google 相关的实现(GoogleApiClient 等),或者有没有办法在没有 google 的情况下生成地理围栏?如何收听地理围栏转换(进入和退出地理围栏)然后发送推送通知?

android openstreetmap push-notification osmdroid android-geofence

0
推荐指数
1
解决办法
1386
查看次数

iOS 上的 Firebase 云消息传递无法正常工作

我添加到我的项目Firebase Cloud Messaging以接收和发送推送通知。我按照 Google 原始教程中的步骤进行操作。结果令人兴奋,我可以在我的设备上收到推送通知- 我将其发布到TestFlight - 出现问题

我意识到我需要创建不同的证书。(???) 然后我从 Firebase Cloud 消息传递中删除了我的密钥 (.p8) 并重新创建了它(开发也是如此)+ 我重新创建了相同的开发配置文件(我撤销了旧配置文件),我从教程中重复了过程,但现在我不能即使在我的设备上能收到推送通知,无论是在 TestFlight 上。

任何人都可以帮我解决这些问题吗?

  1. 我应该创建哪个证书/配置文件?现在,我已经为开发创建了 .p8 密钥和用于开发的配置文件(不再工作)
  2. 我应该更改代码中的某些内容吗?我发现我应该在某个地方将 URL 从沙盒更改为 prod,Firebase 会自动执行吗?设备令牌有问题吗?当我将 FCM 令牌复制/粘贴到控制台时,我什至无法收到测试通知。
  3. 可以从 Firebase 消息控制台发送静默推送通知吗?(我可以在 Firebase 控制台中设置所有必需的标头吗?)
  4. .p8 和 .p12 之间的区别?可以使用 .p8 密钥进行生产吗?

请帮我解决这个问题。谢谢!

[更新][已解决]完成此答案中的步骤并将Firebase 中的团队 ID 更改为来自 Apple 开发人员的相同团队 ID 后,我能够收到我的设备和所有 TestFlight 设备的通知。

push-notification apple-push-notifications ios firebase swift

0
推荐指数
1
解决办法
9597
查看次数