简体   繁体   English

iOS的离子推送通知

[英]Ionic push notification for iOS

I'm doing an Ionic project with Notifications functionality and it works for Android but with iOS, I am having a lot of problems. 我正在做一个具有Notifications功能的Ionic项目,它适用于Android,但对于iOS,我遇到了很多问题。 I read and did all the steps in the Ionic guide to implementing Push Notifications: https://docs.ionic.io/services/push/ 我已阅读并完成了Ionic指南中有关实施推送通知的所有步骤: https//docs.ionic.io/services/push/

In summary: I create Cloud Notification Client for my app, and I added ionic cloud like this: 总结:我为我的应用程序创建了Cloud Notification Client,并添加了离子云,如下所示:

npm install@ionic/cloud --save

and add the files to my index.html I define the Promise installing: 并将文件添加到我的index.html中,我定义了Promise安装:

npm install bluebird --save

And I configurated my app: 然后我配置了我的应用程序:

angular.module('starter', ['ionic', 'ionic.cloud', 'starter.controllers', 'starter.services'])

.config(function($ionicCloudProvider) {
  $ionicCloudProvider.init({
    "core": {
      "app_id": "APP_ID"
    }
  });
}) 

Then to configure the Notifications to iOS I did the same that this guide: https://docs.ionic.io/services/profiles/#android-gcm-project--api-key 然后,将通知配置为iOS,我做了与本指南相同的操作: https : //docs.ionic.io/services/profiles/#android-gcm-project--api-key

  1. Register app ID 注册应用ID
  2. Device Registration 设备注册
  3. Create signin Request with keychain. 使用钥匙串创建登录请求。
  4. I created iOS App Certificate & Provisioning Profile 我创建了iOS应用证书和配置文件
  5. Convert .cer in .p12 在.p12中转换.cer
  6. I did the provisioning profile of my app 我做了我的应用程序的配置文件
  7. I went to the Ionic Cloud Dashboard and updload the .p12 and .mobileprovision to my Profile 我去了Ionic Cloud Dashboard,并将.p12和.mobileprovision上传到我的个人资料中
  8. Create the iOS push Certificate of my app 创建我的应用的iOS推送证书
  9. And then I upload this certificate to the Ionic Cloud Dashboard. 然后,我将此证书上传到Ionic Cloud仪表板。

Finally I did the set up in my app, and build and run in a real device, android and iOS. 最终,我在我的应用程序中进行了设置,并在真实的设备(Android和iOS)中构建并运行。 The problem is that in Android it works perfectly, but in iOS I save the token perfectly but nothing arrive when I send the notification from Ionic Cloud Dashboard. 问题在于,在Android中它可以完美运行,但是在iOS中,我可以完美地保存令牌,但是当我从Ionic Cloud Dashboard发送通知时,什么也没有到达。

Any help? 有什么帮助吗?

Thanks a million! 太感谢了!

I may be very late in answering your question.Answer is as follows.. 我回答您的问题可能很晚。答案如下。

  1. Update your ionic to version v2 and above, use command "$npm install ionic cordova " for that. 将您的ionic更新到v2及更高版本,为此使用命令“ $ npm install ionic cordova”。
  2. Then follow this one carefully http://nishanthkabra.com/ionic2push.html you can implement it very easily. 然后,请仔细按照http://nishanthkabra.com/ionic2push.html进行操作,您可以非常轻松地实现它。
  3. I also suggest rather then ionic.io use java or php code for sending push notification, because they will be very easy for customization. 我还建议,而不是ionic.io使用Java或php代码发送推送通知,因为它们很容易自定义。

At first Install following Plugin under your project 首先,在您的项目下安装以下插件

cordova plugin add https://github.com/phonegap/phonegap-plugin-push 科尔多瓦插件添加https://github.com/phonegap/phonegap-plugin-push

You will also need a .pem file and passphrase, you can follow this link for generating them: Generate .pem file Used to setup Apple PUSH Notification 您还将需要一个.pem文件和密码,您可以通过此链接生成它们: 生成.pem文件用于设置Apple PUSH通知

Download following code from here: https://drive.google.com/open?id=0B_-b-DfCLwKdREkwZFdYVEhYWXM 从此处下载以下代码: https : //drive.google.com/open?id=0B_-b-DfCLwKdREkwZFdYVEhYWXM

Then merge code in your app.js and after that run your application in iphone and check in console device if you are getting token or not, if device token is showing then move on to next step. 然后,将代码合并到app.js中,然后在iphone中运行应用程序,并在控制台设备中检查是否要获取令牌,如果正在显示设备令牌,请继续执行下一步。

Then you can store device token in database when user login or register. 然后,您可以在用户登录或注册时将设备令牌存储在数据库中。

Then enter your [.pem] file location and pass phrase in [db.class.php] 然后在[db.class.php]中输入您的[.pem]文件位置和密码短语

Then enter device token in [sendIphonenotification.php] file 然后在[sendIphonenotification.php]文件中输入设备令牌

Then execute [sendIphonenotification.php] file and check your iphone you will get a notification. 然后执行[sendIphonenotification.php]文件并检查您的iPhone,您会收到通知。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM