Attempting to sent Push Notifications to iOS device - not receiving them - ios

I have so far done the following:
- Generated certificate and private key as .pem, also cat'd them together. Successfully connected to gateway.sandbox.push.apple.com.
- Using the provisional profile with push notifications is enabled for development, I have a basic app that successfully prompted "Do you want to allow push notifications", so this is working correctly
- Obtained the device token
- I have tried pulling a few pre-made files for SSLing into sandbox from the internet just to see if I can get them running before I start development.
The files are the php file posted here: http://www.raywenderlich.com/3443/apple-push-notification-services-tutorial-part-12. I actually got a "Message successfully sent"
The python file posted here: Apple PNS (push notification services) sample code; I had to edit the Python 3 command "fromhash" line to str(float.fromhash(...))
I also tried using the PyAPNs API: https://github.com/simonwhitaker/PyAPNs. I still have use_sandbox set to true.
Obviously I changed the device tokens and public keys/certificates to my own. Sadly I have not received any pushed notifications yet, and I'm not receiving any concrete errors to tell me why. If anyone can shed some light, that would be amazing.

From my comment in radesix's answer, and apologies that I can provide no more detail as it's been a year since I've touched iOS development.
The problem was my provisional profile had the "aps-environment" key set to developer, but for some reason xcode defaulted to "debug". Changing this in the editor solved my problem.

Use a service like urban airship (urbanairship.com) and you'll have this up and running in minutes. Less for you to maintain in the long run also.

Related

Why the Flutter phone authentication won't work my real device

I have encountered a strange problem. I'm using the Flutter tool to create my iOS app which requires Firebase phone authentication. I was able to make it work on the other app platform without any fuss, but I'm not able to make it work on iOS real device. As per the documentation, I have to register an APN key from the developer account which I did and added my app's bundle ID too. This key I had to upload in my app console in Firebase which I also did. The REVERSE_CLIENT_ID was entered in the project settings in Xcode too, so the simulator version works flawlessly.
However, when it came to make it work on the real iPhone, I get this issue
flutter: exception code verifyPhoneNumberError message Invalid token.
I just am not able to make out what the issue is. One thing to note is that I had created a native Swift version using same APN key with different App ID for test purpose. Could this be a cause? Should I create a new APN key and will that allow my old App ID?
I got it working by doing a couple of things. I don't really know which one is the actual reason of it working, but along with official docs, I also followed this blog post https://medium.com/flutter-community/flutter-adding-sign-in-with-google-and-phone-authentication-to-your-app-69f681518f9b for help and achieved it due to the blogger's additional help when asked.
Basically I created a new APN key altogether for both push notifications and Firebase phone authentication, then uploaded in Firebase console (removing my old one). Later, the blogger suggested I also enable Background modes for remote notifications in my Xcode project settings. I didn't know this, as I had thought the Push Notifications switch was enough. Anyhow, bam! it started working.

push Notification not working in ios ionic using FCM

i have setup all the steps for push notification using https://firebase.google.com/docs/cloud-messaging/ios/first-message#access_the_registration_token but i didn't get notification in ios App but working in Android App and also with http://pushtry.com .how to resolve this issue
I was facing the same problem and after searching for a day here are my conclusions:
Don't forget to allow for push notification in your App ID.Click on edit and then enable push notification.
Make sure your certificates you are using are correct because as you allow for push notification your previous profiles become invalid(In my case they were).So either edit the provision profiles and download again or create new ones.
3.I'll prefer using Apn-auth key as suggested on main firebase site instead of apns certificates.
4.One of the major point which I was missing was the problem with xcode Enable push notification there in the xcode as well which
are not enabled by default.
If your app is closing soon after opening your plist might be the cause Follow this answer for solution .
Last thing that really helped me fix the issue was a mac OS update.I was trying to build using xcode 7.2 which was quiet dumb part on my
side.There when I tried to enable push notification.It made changes to
my certificates and then I downloaded the provisional profile after
editing them(So valid now) and then build and everything started
working fine as hell.

Firebase Cloud Messaging Push Notificartions don't arrive on iOS anymore

I have a problem with Firebase Cloud Messaging on iOS. I have implemented Firebase into the app like stated in the docs and a Firebase instance id is generated. However, if I try to send a push notification (for example using http://pushtry.com/), nothing happened. The thing is, it did work, and I don't remember changing anything to do with notifications.
Because I couldn't find anything, I even tried deleting the whole project and doing everything again from scratch (by copying the code). Then it worked again, but now (an hour later) again, it again doesn't work.
If I send a FCM from pushtry or from the Firebase Console, it says the message is delivered, but nothing happens! (Push notifications are enabled in the iOS Settings. It did work)
I really don't know what to do. Does anybody know about anything I could do?
Thank you in advance.
Okay after two whole days of utmost frustration, I figured it out.
The problem was the line FirebaseAppDelegateProxyEnabled set to NO in the info.plist file.
After I removed the line, the problem was gone!
I am so relieved right now
set parameter content_available to true
In my case, I had migrated my Apple account and forgot to configure both my Apple and Firebase account correctly.
Apple side
Make sure that "Push Notification" is enabled for that app id.
Make sure that you had created "Apple Push Notification service" certificate and attached to the Apple Id.
Create an Authorization Key that will be later updated load Firebase so it can communicate with Apple servers in your behalf. (link)
Firebase side
Make sure your iOS apple bundle is set correctly in your Firebase project
Upload the Authorization key you created before in Apple - Step 3 above. (link)
Follow all the steps to have the iOS app integrated with Firebase SDK
That is it.

Testing Amazon SNS for iOS using the Mobile Hub but can't get it to work

Per the title, I'm trying to get AWS SNS push notification to work on iOS device. For testing purpose I wanted try the Mobile Hub (https://console.aws.amazon.com/mobilehub) and work my way on top of the sample app that's given.
I just can't seem to make it work. I know it's difficult to ask for help when it involves a multi layered instructions, but I've spent all weekend wrestling this issue, and just couldn't seem to figure it out.
In AppDelegate, didReceiveRemoteNotification call should receive something when I trigger an SNS within Amazon SNS Mobile Console after selecting a Topic. But this protocol is not being called.
In terms of Provisioning Profile, I've created both Development & Distribution. Tested with both.
In terms of certificates I have tried with both Apple Push Notification service SSL (Sandbox) and Apple Push Notification service SSL (Sandbox & Production). It's obvious you have to select the latter since with the former, the notification permission alert doesn't even show when you install the app. Only does it show when you've installed it with the latter.
I made sure the bundle IDs match.
I've turned on all my notifications on my iphone 6s.
On console I see this success message:
2016-03-30 20:57:57.103 MySampleApp[284:47861] AWSiOSSDKv2 [Info] AWSPushManager.m line:186 | -[AWSPushManager interceptApplication:didRegisterForRemoteNotificationsWithDeviceToken:] | The device token: 435d5se354s38s9ddge2edcs2a3601e18ss9c83e47s629164ebced21s16abb39974sg3
"didFailToRegisterForRemoteNotificationsWithError" never gets called.
"didRegisterForRemoteNotificationsWithDeviceToken" successfully gets called.
I also get this success message on my console:
2016-03-30 21:34:16.635 MySampleApp[321:57551] AWSiOSSDKv2 [Info] PushNotificationViewController.m line:112 |
-[PushNotificationViewController topicDidSubscribe:] | Successfully subscribed to a topic: AWSPushTopic: 0x14c6da770
I'm absolutely lost. Please let me know if there is more info for me to post to solve this issue.
Update: Rohan Dubal, thanks for the comment. Here are the following things you asked me for.
Yes, I have always went from "My Sample App" navigationbar view -> "Push Notifications" row -> "Push Notifications" navigation bar view -> click Demo Push Notifications on the bottom -> the toggle is on (green) and the "topic" line is checkmarked and I have sent the APNS to that referring Topic.
Yes I've tried minimizing and also closing the app as well. The top bar notification or any notification doesn't show at all.
Thanks for your feedback. Please do suggest any other tests I can run.
Also, I thought that maybe it has to do w/ my iphone 6s so i tried it w/ iphone 5s and it still doesn't work.
iphone 6s is ios9.2 and iphone 5s is ios 8.3.
Well, this sounds similar to the problem that I was just having. Mobile Hub only seems to let you setup Production APNS and not Development ones. When I debug the app with XCODE I'd need to use the sandbox APNS, so I did the following:
Create an SNS Application of type Apple Development (APNS_SANDBOX)
Use the .p12 from my Development Certificate in the App ID
Started my App and recorded the device token that didRegisterForRemoteNotificationsWithDeviceToken gave me
Minimised my App (otherwise notifications don't appear)
in SNS console I registered an Endpoint using the device token
Used the Publish to this Endpoint button in SNS console to send a message ('Hello World', obviously)
Saw notification
Did engineers victory dance
Hopefully that helps you. The key to this for me was realising that I'd need to create another SNS queue. TBH I'm not seeing the benefit of the Mobile Hub.

Development Push vs Distribution Push

We are having some trouble with our push services here..
Our app has been on AppStore for a while, and we wanted to try out our Push for the first time. Not to send to everyone, just to my device.
We followed this guide for setting everything up, and it worked perfectly during development. Later, we did the same thing with distribution when the app went live on AppStore. (perhaps not in that order)
Anyway, we never really tested the push after it went live (our service is kind of a news-service, and is supposed to send a notification to ALL devices when we choose to).
I ran a debug to register my device's token in a different sql-table than the rest, and re-downloaded out app directly from appstore. I do not get prompted for registering for notifications, but I know I did this the first time, and I can even see it in Settings.
I used our .php website to send a message to 'all' devices in the table (currently only my device), and I go nothing. I downloaded the same app on my iPad, and the token was added to the database, sent a new message, and none of them received it.
We added my colleague's token to the same database, he downloaded the app from AppStore, sent the message to all devices in the new table(now three devices), and only HE got the message.
His phone might contain some of the earlier important profiles, but this is all in production, and that shouldn't have anything to say, right?
I now have NO clue what to do. I figure either both my iPhone and my iPad are broken or ignored by the push service, OR my colleague's phone is the only device that will ever receive a notification from this service..?
When I use .php-code to fwrite and send the notification to gateway.push.apple.com, it returns that it successfully sends the message to all devices (but this is also the case even if the app has been deleted from the device.)
I made the .pem file myself, from a newly created request/key/profile etc. from my machine.
Is there a reason why our push service does not send to my devices? Or so far only to his?
Could it have anything to do with certificates, provisioning profiles, keys etc?
EDIT
We have now been trying a whole buch of stuff, and it kind of works now, but I have NO IDEA what happened, and how it works now.
What we did:
My colleague opened his XCode-project, and set everything to Release, and pressed Build. He sent me the AppName.app, and I dragged this to iTunes, and told it to install that app. (The only difference between the AppStore-version and the Xcode-version now, is that DeviceTokens should be registered in another table, as I mentioned earlier). When I launched the app, I noticed that a fourth Token was registered. What I mean by that is that the deviceToken of my device had changed. I know that this happens from time to time, but it shouldn't be a problem. When I tried sending a notification with the new app and the new token registered, I received it. If I UNINSTALL the version he sent me, and re-download the AppStore-version, and send a notification to the NEW device-token, I now receive it.
How?
If I cross check the device tokens in the new with the old table, they are both on both.
The method I used to get a hold of my Device Token in the first place was to build my project with a different url somewhere in it, and I had to delete the AppStore-version first. When running this 'new' xcode-version, it spit out a new token that was never registered with the AppStore-version, so when I tried to reinstall the AppStore-version and send a notification to only that token, it never came through - because the 'current' deviceToken was hidden in the original table, and not in the new one.
The new question:
Why would my deviceToken change from one build to another?
To make a clearer image of what I think happened:
1. AppStore-app launch - Table.regDeviceToken = 111;
2. AppStore-app launch2- Tabke.regDeviceToken = 222; //(it updated itself)
3. Xcode launch - Table2.regDeviceToken = 111; //This is the Token I found and used
4. AppStore-app lauch4 - Table1.regDeviceToken = 222 //This is hidden from me, I thought it would be 111.
5. Send push to Table2.DeviceToken=111; //Which does not work
6. Send push to Table.DeviceToken = 222; //Which works
So, when launching the app in Xcode, I got the OLD DeviceToken. Why would this happen?
Okay, after a lot of headaches due to this problem I have finally found the answer. Our service has functioned properly this whole time.
When I was acquiring my device Token using my Xcode-project, I got a device token made for Development. When I then tried to send a push-notification to this token using our AppStore-app, it did not come through.
When I got the AppName.app file from my colleague, it obviously was in Production/Release-mode, and thus giving the database a DIFFERENT deviceToken.
Bottom line:
An application gives different deviceTokens for Debug vs Release.

Resources