我们完全卡住了,请帮忙。
我和我的团队制作了一个 iPhone 应用程序,这是我们第一次在 iOS 上尝试。
一切都很好,直到我们提交了我们的应用程序并在应用程序商店上可用——推送通知服务不工作。我在网上搜索并尝试按照人们的建议仔细检查我们的应用程序,但我找不到问题所在。所以这个问题发布在这里。
这些是我们所做的:
我们构建应用程序,假设它被命名为“AppMaster”。
我们在名为“pushtest”的 iOS Provisioning Portal 上创建了 AppId。此 ID 在开发和生产中启用了推送通知。
我们从上面的 appId 创建了一个名为“AppMasterPushTest”的开发配置。此配置用于内部测试,团队中的每个人都将其安装在他们的 mac 上。
我们的服务器是用Java实现的,我们使用了java-apn包。在测试期间,我们下载了用于开发的认证文件并写出 .p12 文件,并使用包的 api -- withSandboxDestination() 和该 .p12 文件将我们的消息推送到“沙箱”服务器。测试顺利,收到通知。
我认为我们已经准备好了,所以我们创建了另一个名为“AppMaster”的 AppId,并仅为生产启用推送通知。这个 Id 写在应用程序的包标识符中。
我们在第 5 步中从 AppId 为生产创建了另一个名为“appMaster”的配置,分发方法设置为“App Store”。下载它并重建应用程序。这个已提交给 apple,并在 app-stroe 上运行。
服务器端,我们下载生产认证并再次写出 .p12 文件。并制作程序通过使用 api -- withProductionDestination() 将消息推送到生产服务器,其中.p12 刚刚被写出。
我们从 App Store 安装了该应用程序。遗憾的是,通知从未送达。
我们错过了什么吗?顺便说一句,我们在第 5 步中创建的 ID 看起来像“XXX.com.company.appname”,但在应用程序的包标识符中,我们只是设置了没有前缀的“com.company.appname”部分。这可能是问题所在吗?
欢迎任何想法。
请做我们的救星。谢谢。
最佳答案
上面的评论是不正确的。应用 ID 在 bundle ID 之前有一个前缀:
An application ID consists of an application’s bundle ID prefixed with a ten-character code generated by Apple. The team admin must enter the bundle ID. For a certificate, it must incorporate a specific bundle ID; you cannot use a “wildcard” application ID.
您应该检查您的配置文件,以确保它包含正确的 aps 授权:
Verify that the entitlements in the provisioning-profile file are correct. To do this, open the .mobileprovision file in a text editor. The contents of the file are structured in XML. In the Entitlements dictionary locate the aps-environment key. For a development provisioning profile, the string value of this key should be development; for a distribution provisioning profile, the string value should be production.
您应该确保在向生产 APNS 服务器发送推送通知时使用生产设备 token (在沙盒环境中工作的设备 token 在生产环境中不起作用)。
在将应用发布到应用商店之前,您应该使用 AdHoc 配置文件测试您的应用。 AdHoc 配置文件适用于生产推送环境。
编辑:
关于设备 token 的一些引述:
来自Local and Push Notification Programming Guide :
Take note that the device token in the production environment and the device token in the development (sandbox) environment are not the same value.
Handling Malformed Notifications
The simple binary interface drops the connection if the push service receives a notification that is incorrect in some way. Your provider may see this as an EPIPE or broken pipe error in response to sending a notification. On the other hand, the enhanced binary interface will send an error response with more detailed information about what was wrong with the notification before dropping the connection. Be sure your provider catches and handles these conditions properly.
The most common problem is an invalid device token. If the token came from the sandbox environment, such as when you are testing a development build in house, you can't send it to the production push service. Each push environment will issue a different token for the same device or computer. If you do send a device token to the wrong environment, the push service will see that as an invalid token and discard the notification.
最后,this article很好地解释了当某些通知无效时(最常见的原因是设备 token 无效)如何向 Apple 发送多个通知会导致某些有效通知也无法到达。
关于iphone - 苹果推送通知在生产中不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15595720/
大约一年前,我决定确保每个包含非唯一文本的Flash通知都将从模块中的方法中获取文本。我这样做的最初原因是为了避免一遍又一遍地输入相同的字符串。如果我想更改措辞,我可以在一个地方轻松完成,而且一遍又一遍地重复同一件事而出现拼写错误的可能性也会降低。我最终得到的是这样的:moduleMessagesdefformat_error_messages(errors)errors.map{|attribute,message|"Error:#{attribute.to_s.titleize}#{message}."}enddeferror_message_could_not_find(obje
如果您尝试在Ruby中的nil对象上调用方法,则会出现NoMethodError异常并显示消息:"undefinedmethod‘...’fornil:NilClass"然而,有一个tryRails中的方法,如果它被发送到一个nil对象,它只返回nil:require'rubygems'require'active_support/all'nil.try(:nonexisting_method)#noNoMethodErrorexceptionanymore那么try如何在内部工作以防止该异常? 最佳答案 像Ruby中的所有其他对象
在Rails4.0.2中,我使用s3_direct_upload和aws-sdkgems直接为s3存储桶上传文件。在开发环境中它工作正常,但在生产环境中它会抛出如下错误,ActionView::Template::Error(noimplicitconversionofnilintoString)在View中,create_cv_url,:id=>"s3_uploader",:key=>"cv_uploads/{unique_id}/${filename}",:key_starts_with=>"cv_uploads/",:callback_param=>"cv[direct_uplo
有人知道在发布新版本的Ruby和Rails时收到电子邮件的方法吗?他们有邮件列表,RubyonRails有一个推特,但我不想听到那些随之而来的喧嚣,我只想知道什么时候发布新版本,尤其是那些有安全修复的版本。 最佳答案 从therailsblog获取提要.http://weblog.rubyonrails.org/feed/atom.xml 关于ruby-on-rails-如何在发布新的Ruby或Rails版本时收到通知?,我们在StackOverflow上找到一个类似的问题:
我目前正在尝试学习RubyonRails和测试框架RSpec。assigns在此RSpec测试中做什么?describe"GETindex"doit"assignsallmymodelas@mymodel"domymodel=Factory(:mymodel)get:indexassigns(:mymodels).shouldeq([mymodel])endend 最佳答案 assigns只是检查您在Controller中设置的实例变量的值。这里检查@mymodels。 关于ruby-o
我有一个数组数组,想将元素附加到子数组。+=做我想做的,但我想了解为什么push不做。我期望的行为(并与+=一起工作):b=Array.new(3,[])b[0]+=["apple"]b[1]+=["orange"]b[2]+=["frog"]b=>[["苹果"],["橙子"],["Frog"]]通过推送,我将推送的元素附加到每个子数组(为什么?):a=Array.new(3,[])a[0].push("apple")a[1].push("orange")a[2].push("frog")a=>[[“苹果”、“橙子”、“Frog”]、[“苹果”、“橙子”、“Frog”]、[“苹果”、“
这段代码似乎创建了一个范围从a到z的数组,但我不明白*的作用。有人可以解释一下吗?[*"a".."z"] 最佳答案 它叫做splatoperator.SplattinganLvalueAmaximumofonelvaluemaybesplattedinwhichcaseitisassignedanArrayconsistingoftheremainingrvaluesthatlackcorrespondinglvalues.Iftherightmostlvalueissplattedthenitconsumesallrvaluesw
你能解释一下吗?我想评估来自两个不同来源的值和计算。一个消息来源为我提供了以下信息(以编程方式):'a=2'第二个来源给了我这个表达式来评估:'a+3'这个有效:a=2eval'a+3'这也有效:eval'a=2;a+3'但我真正需要的是这个,但它不起作用:eval'a=2'eval'a+3'我想了解其中的区别,以及如何使最后一个选项起作用。感谢您的帮助。 最佳答案 您可以创建一个Binding,并将相同的绑定(bind)与每个eval相关联调用:1.9.3p194:008>b=binding=>#1.9.3p194:009>eva
我无法运行Spring。这是错误日志。myid-no-MacBook-Pro:myid$spring/Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/lib/spring/sid.rb:17:in`fiddle_func':uninitializedconstantSpring::SID::DL(NameError)from/Users/myid/.rbenv/versions/1.9.3-p484/lib/ruby/gems/1.9.1/gems/spring-0.0.10/li
我在RoR应用程序中有一个提交表单,是使用simple_form构建的。当字段为空白时,应用程序仍会继续下一步,而不会提示错误或警告。默认情况下,这些字段应该是required:true;但即使手动编写也行不通。该应用有3个步骤:NewPost(新View)->Preview(创建View)->Post。我的Controller和View的摘录会更清楚:defnew@post=Post.newenddefcreate@post=Post.new(params.require(:post).permit(:title,:category_id))ifparams[:previewButt