I'm having a trouble to get the information from push notification and it only happens on iOS7, I have tested on iOS5 and iOS6, the function works perfectly fine. Here is the scenario: I have a game playing between 2 iPhones and it's a turn-base game, in every move, there will be a push notification sent to each competitor announce that the other one has made the move and now is your turn.
The problem is, when I lock my iPhone (turn off the screen) and the other made the move, there IS the push on my iPhone, and I slide to unlock, obviously the app appear but the 'didreceiveremotenotification' has not been invoked.
It's weird that only happens on iOS7. I know there are only 3 states that the application will get the push notification supspended/background/foreground. what state is the lockscreen? Any helps would be great and sorry for my English, if I didn't make it clear, please leave the comment, I will explain more.
Related
That's really weird problem..my notifications is working perfectly but in very random and rare cases, the screen just is woken up but no notification appears.
Although I'm using native Swift, it seems it's a common problem
IOS Push notification - Sometimes only wakes screen and plays sound
Do you have any suggestions?
If you have a line of code that reduces the application badge number when a notification is received, make sure that this line doesn't get called when app state is not "Active".
I am currently working on an iOS app and i need some help.
I want the app to be able to notify the user about something in form a "push notification" even when the phone locked. The push notifications work fine when the phone is not locked but as soon as i lock the phone it wont give me any sound or vibration. It will only show me the visual part of the notification but it comes in completely silence. It does not even light the screen up when the notification gets pushed to the user.
I currently use
content.sound = UNNotificationSound.default()
And it works fine with sound and vibration when the phone is unlocked.
Is it because i need to do something with my settings? do i need any code to do such thing? do i need to have developer account?
Any help would make me really happy!!
3 STEPS TO HOPEFULLY RECOVER SOUND ON YOUR IPHONE FOR INCOMING NOTIFICATIONS.
Check that the ringer on the left of the phone doesn’t show an orange line – indicating sound switched off. If so, slide it to the right so only white is showing. This may have fixed it.
Swipe up from the bottom of the screen to reveal symbols, music etc. Ensure that the half moon symbol is grey and not white. If it’s white touch it to make it grey – this will switch off do not disturb. This may have fixed it.
Check your settings, Do not Disturb half moon icon, ensure that Manual is off and not showing a green on icon. If it is, touch the green icon which will make it white and switch it off. This may have fixed it.
(I hope that helps, it worked for my iphone 5C as I’d inadvertently switched on Do Not disturb as shown in step 2. above.)
Just an FYI if someone else is having this same issue. I was having the same troubles getting my notifications to come through on my phone when it was locked.
I realized the issue was I was building to my physical device which was also attached to the Apple Watch I was wearing. Since my watch is set to mirror my iPhone notifications the phone didn't play them as it expected my watch to take over when was locked. However, every time you build & run your app it takes a few minutes for your watch to recognize your app and take over the user notifications.
The solution here is to either wait 10 minutes or so after building and then try firing off a notification (which should appear on your watch) OR simple take off your watch before you build & run.
This question already has answers here:
How to detect push notification sent to other apps?
(2 answers)
Closed 6 years ago.
I'm working on an iOS game that has a score counter and some buttons at the top of the screen. When I receive any push notifications for a different app (e.g. a new email), the push notification covers the top of the screen for a few seconds, which is annoying when you're in the middle of a game. I would like to know whenever a third-party notification is being displayed, so that I can move the score counter and buttons below the push notification while it is being shown.
Is this possible?
Unfortunately, as of now (and probably forever) there is no API or way to interact with Apple's Notification Center, and thus it's impossible to know when a third-party notification is displaying. This is primarily because they strive to keep a consistent user experience across their entire platform at the developer's expense. The closest you can get is knowing when an application has left and entered the foreground (which will happen when they tap that notification) to properly pause the game
Thankfully, users can dismiss the alerts really quickly with a swipe of a thumb, but regardless, it's still annoying. Maybe make some small adjustments to your UI with this knowledge and have less user taps necessary at the top of the screen?
Good luck!
UPDATE - a warning to anyone with similar symptoms... check Do Not Disturb is not active!
I finally paid to get an app I was working on running on my iPhone instead of on the simulator.
Having done so I've spotted a strange behaviour with regards to the UILocalNotifications that I create, which are set to use the default sound UILocalNotificationDefaultSoundName, and the default timezone ([NSTimeZone defaultTimeZone]).
If the app is foregrounded then the local notification fires on time and I receive it within
- (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
and I create an alert view to display it.
If however I lock my phone just before a notification is expected then nothing appears on the screen, but when I press the home button to show the lock screen I can see my app's notification in the notification centre on the lock screen. No sound was played, but then again the phone didn't wake up to show the notification properly.
If however I just press the home button so the app is put in the background leaving me looking at the springboard apps then I don't see any notifications whatsoever, and again no sound is heard.
On the simulator the same code correctly fires the notification banner when looking at the app icons in the spring board, although I've never been able to hear any sounds for the notification. But as the simulator doesn't let you configure the notification centre for apps I always presumed it was perhaps set to not allow sounds. On my device sounds for this apps notifications are enabled, and i've tried it with banner and alert modes, with no joy. Very frustrating.
Has anyone experienced this, or have an idea what could be going on?
Oh the irony of this answer.. think it's time to go to bed. My iPhone thinks that too for nearly 3 hours now... My question happily describes Do Not Disturbs behaviour, which was active.. Sorry to waste everyones time!!
Got 2 questions for the xcode experts :
- I would like to send a (repeating) local notification only to the locked screen but without having the screen turning on, it is possible ?
- I also would like to check whether the screen is on or off (for this very purpose) : is there any way with the current IOS version (IOS 7) ?
Many thanks for any help !
No this is not possible, frits it will be very hard to get you app running in background without misusing one of the background modes.
You cannot detect if the devices is locked and you will flood the notification center with messages.
If you do manage to get it working then there is good chance that Appel will reject your app for doing this.
You can check the screen by checking the applicationState property, which will be set to UIApplicationStateInactive when the phone is set to lock/sleep (as opposed to UIApplicationStateBackground).
As for the notification, you can set a push notification delegate (I've not done it from scratch, but I did it using Urban Airship and creating my own custom push handler class) and handle whether to post an alert or not there. I'm not sure, though, whether having the phone sleep will kick notifications to the OS level, which would default to showing a notification on the screen.