标签: apple-push-notifications

Iphone Sdk:是否可以使用UISwitch启用和禁用PNS(推送通知服务)?

在这里找到一些关于PNS的示例代码

我还创建了一个UISwitch来启用PNS

如何给出控制PNS的方法?

这就是我宣告细胞的方式

cell.textLabel.text = @"PNS";
  [cell.textLabel setTextColor:[UIColor grayColor]];
  pushNotificationSwitch = [[[UISwitch alloc] initWithFrame:CGRectZero] autorelease];
  [cell addSubview:pushNotificationSwitch];
  cell.accessoryView = pushNotificationSwitch;
  [(UISwitch *)cell.accessoryView addTarget:self action:@selector(pushNotification:) forControlEvents:UIControlEventValueChanged];
 }


- (void)pushNotification:(id)sender{
 if (pushNotificationSwitch.on==YES) {
  UITableViewCell *cell = (UITableViewCell*)pushNotificationSwitch.superview;
  [cell.textLabel setTextColor:[UIColor blackColor]];
 }
 else {
  UITableViewCell *cell = (UITableViewCell*)pushNotificationSwitch.superview;
  [cell.textLabel setTextColor:[UIColor grayColor]];
 }
} 
Run Code Online (Sandbox Code Playgroud)

现在我只是使用单元格的文本标签颜色更改来表示交换机调用该方法

所以...我可以用它来控制PNS启用与否???

感谢您的任何意见和解答!

iphone sdk push-notification apple-push-notifications uiswitch

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

通过APNS批量发送自定义消息到设备

我正在使用notnoop APNS Java库来发送APNS通知.由于我们拥有大量用户,因此我们需要批量发送APNS通知.根据notnoop API,以下方法似乎是最佳选择:

push(Collection<String> deviceTokens, String payload)
Run Code Online (Sandbox Code Playgroud)

http://notnoop.github.com/java-apns/apidocs/com/notnoop/apns/ApnsService.html

此方法批量发送单个消息到多个设备.我们希望为每个设备发送不同的特定消息,但仍然批量发送所有通知.我没有在notnoop库中找到任何适当的方法来执行此操作.有没有人有这方面的经验?用notnoop库可以做到这一点吗?Apple APNS服务器是否支持这种推送?

提前致谢!

最好,J

java apple-push-notifications ios

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

在应用未运行iPhone时获取推送通知

我正在开发一个涉及推送通知的iPhone应用程序.正如我在许多文档和教程中看到的那样,它建议用in注册推送通知

application:(UIApplication *)application 
  didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
Run Code Online (Sandbox Code Playgroud)

如下:

- (BOOL)application:(UIApplication *)application 
  didFinishLaunchingWithOptions:(NSDictionary *)launchOptions 
{   
    [[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeAlert| UIRemoteNotificationTypeBadge|  UIRemoteNotificationTypeSound]; 

    ...
} 
Run Code Online (Sandbox Code Playgroud)

现在的问题是,如果应用程序没有运行(即使在后台),当推送到来时,它无法处理推送消息,但如果我再次从通知区域使用推送消息并再次午餐应用程序,我可以得到我的留言

我需要做些什么来让我的应用程序获得推送消息,即使它第一次吃午饭?

iphone push sandbox apple-push-notifications

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

如何以编程方式激活ios通知设置?

我的应用程序注册了这样的通知:

[[UIApplication sharedApplication] registerForRemoteNotificationTypes:UIRemoteNotificationTypeBadge | UIRemoteNotificationTypeSound | UIRemoteNotificationTypeAlert];
Run Code Online (Sandbox Code Playgroud)

但如果我手动转到通知设置,禁用所有内容(通知中心,警报,声音,徽章),然后卸载并重新安装应用程序(或只是重新安装而不先卸载),我的iPhone保留旧的设置.如何在重新安装时强制重新激活这些设置?

settings apple-push-notifications ios

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

通过AWS Java SDK发送带有声音的iOS的SNS(AWS)消息应该是什么Json字符串?

我绝对打破了我的脑袋.我有代码,用于发送iOS的SNS(AWS):

PublishRequest publishRequest = new PublishRequest("arn:aws:sns:us-east-1:my:topic", messageBody);
Run Code Online (Sandbox Code Playgroud)

当我像这样经过Json时,它工作正常:

{"message": "ldjldkjlk"}
Run Code Online (Sandbox Code Playgroud)

但我当然需要声音通知我,没有什么对我有用.我尝试使用Json,当我将它传递给SNS GUI时,它就是这样的:

{"message": { 
    "default": "HERE IS AN ALERT, BADGE, and SOUND",
    "APNS_SANDBOX": "{\"aps\": {\"alert\":\"HERE IS AN ALERT, BADGE, and SOUND!\",\"badge\": 1,\"sound\":\"bingbong.aiff\"}}"
}}
Run Code Online (Sandbox Code Playgroud)

但我得到错误:

{"timestamp":1435334944602,"status":400,"error":"Bad Request","exception":"org.springframework.http.converter.HttpMessageNotReadableException","message":"Could not read JSON: Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: java.io.PushbackInputStream@2db14d22; line: 1, column: 15]; nested exception is com.fasterxml.jackson.databind.JsonMappingException: Can not deserialize instance of java.lang.String out of START_OBJECT token\n at [Source: java.io.PushbackInputStream@2db14d22; line: 1, column: 15]","path":"/sns/send"}
Run Code Online (Sandbox Code Playgroud)

他们用PublishRequest做了什么?我应该通过什么?如果有人帮助我会很棒!

java amazon-web-services apple-push-notifications amazon-sns ios

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

如何跨多个 iOS 设备同步推送通知?

如何跨多个 iOS 设备同步推送通知?

场景是:用户在两台设备上安装了一个应用程序。两个设备都会收到远程通知。用户在一台设备上打开应用程序。另一台设备上的推送通知应该会消失。

这是由许多应用程序完成的,例如 Facebook Messenger,但这是如何实现的?

(迅速)

push-notification apple-push-notifications ios

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

具有相同证书的多个 APNS 提供商

我有很多私有服务器,每个服务器都可以为多个 iOS 客户端提供服务。

我想为我的应用程序为这些 iOS 设备中的每一个使用 APNS 通知,并且我正在尝试为我应该创建的提供程序找到架构范例。

我应该创建一个提供程序来为这些私有服务器和客户端中的每一个提供服务,还是应该为每个服务器使用相应的提供程序?这是否取决于我使用的证书?例如,我可以对多个提供商使用相同的证书还是只允许一个?

我还没有在 Apple 的网站上找到明确的内容,但我可以从以下事实中推断出,由于 Apple Developer Site 只提供了一个证书,因此我可以在多个提供商中使用它。

谢谢!

architecture apple-push-notifications ios

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

iOS 无法为远程通知播放自定义声音

我一直在尝试为 iOS 上的通知实现自定义声音。

根据此处示例 3 中的 Apple 文档。我们需要做的就是确保推送通知负载应该是这样的:

{
"aps" : {
        "alert" : "You got your emails.",
        "badge" : 9,
        "sound" : "bingbong.aiff"
    }
}
Run Code Online (Sandbox Code Playgroud)

并且 bingbong.aiff 必须放在应用程序包中。

此外,如果应用程序处于活动状态,我被建议添加以下代码:

- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo
{
    if (application.applicationState == UIApplicationStateActive)
    {
        NSString *path = [[NSBundle mainBundle] pathForResource:@"bingbong" ofType:@"aiff"];
        theAudio = [[AVAudioPlayer alloc] initWithContentsOfURL:[NSURL fileURLWithPath:path]error:NULL];

        theAudio.delegate = self;
        [theAudio play];
    }
}
Run Code Online (Sandbox Code Playgroud)

"bingbong.aiff" 被放置在 "SupportingFiles"

我仍然没有获得远程通知的自定义声音。

我已经完成了与此类似的其他 SO 问题,但这些问题与我正在做的没有什么不同。

  1. 用户收到推送通知时如何播放自定义声音文件?

  2. 远程通知中的自定义声音 iOS 10, swift 3

  3. 更改推送通知声音

objective-c apple-push-notifications ios

2
推荐指数
2
解决办法
4188
查看次数

使用 Node JS 的 AWS SNS 推送通知

我搜索了 AWS 文档并浪费了几个小时,但找不到使用 Node JS 发送推送通知的 API 和代码。有人可以帮助在 Android 和 iOS 设备上使用 Node JS 发送 AWS SNS 推送通知吗?

push-notification amazon-web-services apple-push-notifications node.js amazon-sns

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

XCUITest与通知横幅进行交互。

是否可以在XCUITest中验证通知横幅是否已发送到屏幕?

我可以在通知中添加可访问性标识符,但是当横幅广告发送到屏幕时,让XCUITest与之交互时遇到了问题。我知道XCUITest是在与应用程序分开的进程中运行的,但是想知道是否仍可以与通知进行交互,或者它是否超出XCUITest的范围?

谢谢,

xcode ui-automation apple-push-notifications ios xctest

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