parse push notifications not working ios - ios

I installed Parse sdk on my iphone app. This is for xcode 4.5.
I get the modal request to enable push notifications.
The subscription is successful. The token shows up on the parse web app.
Says 1 user subscribed.
But I dont get a notification from the web app.
I just cant understand what to do here.
All the provisioning madness should be correct.
Was done for development.
I am using the below code to listen for the notifications.
But never gets fired. What am i doing wrong here???
- (void)application:(UIApplication *)application
didReceiveRemoteNotification:(NSDictionary *)userInfo {
NSLog(#"received push %#", userInfo);
[PFPush handlePush:userInfo];
}

Check your app's push notification page in the Parse dashboard, which should be at https://www.parse.com/apps/(your app)/push_notifications. If the push notification doesn't appear there, then your notification didn't get sent, and the problem is on the web app's side.
Try sending the push notification while your app isn't running. If you get the notification, then it's something in your app. If you don't get the notification, then you must have set up the push notification incorrectly somewhere.
Also, Parse has a pretty detailed tutorial.

Related

Rewriting Push Notification Content in iOS

I'm developing a chat application, i want to rewrite Push Notification Content (alert) in iOS.
Suppose the alert came is: +911234567890 : Hi how are you
In this alert +911234567890 is the contact number in my phone named My Tester, i just want to rewrite the push notification to: My Tester : Hi how are you
How it can be implemented
This needs to work if the app is not running also.
May sample code is below for process push:
(void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo fetchCompletionHandler:
(void (^)(UIBackgroundFetchResult))completionHandler
In push notification you can display those content that is received by the push notification. If you want display name with push notification then you have to send it from server.Even you can show in Whats App, Whats App notification doesn't show actual name we have store in phone book.It only show the name which is send by the server

XMPP app terminate and not recive message

I am working in XMPP Application.
When I terminate and kill My Application than,
1)User is Not Connected In XMPP Server. User is Offline. But I want User is Connected and Online. Like Whats App(Appliction).
2)I can't get Any Messages From XMPP Server Side at that time,
- (void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message
This method is not call. So, How Can I get Messages ?
And i also implement Pushnotification but in this way same issue Like,When app is Kill and Terminate than,This method is not call,
- (void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler
So, Please Guide me In Proper Way and Suggest me How to work as like same Whats App(Application).
Also, We can't set VOIP Flag In .plist file Because this way is not Proper and reject by the apple.
My Goal is Only Notification Work As like Whats App.
1)User is Not Connected In XMPP Server. User is Offline. But I want
User is Connected and Online. Like Whats App(Appliction).
Once you closed or minimized WhatsApp the user gets offline (tested on iPhone4s), and messages received in this state are as push notifications.
2)I can't get Any Messages From XMPP Server Side at that time,
(void)xmppStream:(XMPPStream *)sender didReceiveMessage:(XMPPMessage *)message
This method get called only when application is active. So you can not get messages here after you killed your application.
- (void)application:(UIApplication )application didReceiveRemoteNotification:(NSDictionary )userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult result))handler
This method will get called in following scenarios
If your app is active and you got any new push notification.
If your app is in background or killed or not started then system will show only notification on the top bar, once user tapped on notification it will open your application and then the method will get called.
And of course you can not use VOIP.
WhatsApp shows custom notification when user is active in WhatsApp.
You need to send push notification for every message of your conversation. In this case
If user is active then show your custom notification in app.
If user is inactive (i.e. killed or minimized app) then system will show Notification in notification center.
When user taps on notification, system will launch application, and you have to check for app launching conditions (from which source app launched) and according to conditions join server/chat (or groups if you are using group chat).
Once you joined server with your name/nickname, you will get recent chats. You can also get history, you need to specify while joining chat server / group.
Make sure you are disconnecting from server and also from group when your app is getting minimized or killed. Use following methods to disconnect and/or related changes
1. - (void)applicationDidEnterBackground:(UIApplication *)application
2. - (void)applicationWillTerminate:(UIApplication *)application
Hope this will help you, I have implemented same to achieve expected results as WhatsApp.
When your app kill, that time XMPP Deactivate all service.So, you can send webservice to server which can tell - you are offline.
Then after sever can send you Push notification all chat content.
First of all, If your application is terminated then you will receive Push Notification data in
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions
in launchOptions dictionary with key
if (launchOptions)
{
if ([launchOptions valueForKey:UIApplicationLaunchOptionsRemoteNotificationKey])
{
// Your code
}
}
Second, you can use background fetch for retrieving user's message, While background fetch you can connect your stream and fetch messages from XMPP server.
NOTE: WhatsApp's (iOS) version, fetches the message as soon as you open the app, it is connecting to the stream and then fetches the messages.
However you can implement your own logic to customize your functionality.
Read the following document it will help you.
http://xmpp.org/extensions/xep-0168.html
We ned to add priority when the presence of user is set as below:
-(void)GoOnline{
XMPPPresence *goOnline = [XMPPPresence presence];
NSXMLElement *priority = [NSXMLElement elementWithName:#"priority" stringValue:#"-1"];
[goOnline addChild:priority];
[xmppStream sendElement:goOnline];
}
Now to know more about priority, it's role and how it works, read the document from above link.
Hope it may help you :)
Check this link and read the Remote Notifications (iOS 7 and Greater) section which is combining the Background Modes and Remote notifications to download content before launching the app.
You will get the idea and you can implement in your preferred language obj-c or swift.

Push notification on iOS devices

I’m able to send and receive the push notification…In the push notification i will be sending some json encoded data…
Once my device receives the push notification,then if the user taps on the notification banner device can get the json data received by the push notification.…But what if user clears the notification banner,how can the iOS device receive the json data?…Any suggestion guys?…
You can set the content-available flag to 1 and iOS will call your app's delegate.
There are just 2 ways to get push notification details, when application is not working. First one is not very reliable since it will provide you latest push notification only. Second one, you can't really use if you want banner and you want to notify user. Third one is just an alternate way to get latest updates from server.
Get details of last push notification in application Launch method :
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
NSDictionary *dicAPNS = [launchOptions objectForKey:UIApplicationLaunchOptionsRemoteNotificationKey];
Use silent Push notification, where user wont get any notification but you will be able to get notified. This is done by sending "content-available:1" in APNS Payload.
Call an server call to check if you have any update. So you can grab data from server what you might have received in missed push notification.
I think iOS push notification fully depends on user's wish.I think the another web service needs to load all the content of data in push notification, if push notification is disabled or deleted by user.

How to consume iOS Push notification in the app only

I am working on a app, where I need to send a push notification to the app to start processing data as needed.
How do I send a push notification to the device so that instead of showing the alert message, the notification is forwarded to the app - whether the app is in the foreground or background..
I did implement the delegate method :
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler
however this is called only when the app is in the foreground. When the app is in the background the notification shows up on the notification center.
Please advice.
To make this works you need to do few step:
set background mode remote-notification
implement application:didReceiveRemoteNotification:fetchCompletionHandler: method in app delegate
and make sure push notification payload contains key "content-available" : 1
related docs:
App States and Multitasking
Local and Push Notifications in Depth
Is your application using a backend? An example would be Parse or another to store your data.
Parse, for example, allows you to add push notifications that can be customized and changed to get the most out of your application.

send device token to server from apple push notification service

I am working on apple push notification service. Now I have implemented the delegates methods as suggested in apple APNS guide. But this also says that one has to send device token received from APNS to provider server.
I am really confused about this thing.
Because when I launched application it asked me if I want to register for remote notifications but then later it never showed anything like that. At that time I had no code to handle this device token. But now it does not show anything like that even if I have deleted and reinstalled the whole application.
Any help would be greatly appreciated.
My code is this
- (void)viewDidLoad {
[super viewDidLoad];
//registring for remote notifications
[[UIApplication sharedApplication] registerForRemoteNotificationTypes:(UIRemoteNotificationTypeAlert | UIRemoteNotificationTypeBadge |UIRemoteNotificationTypeSound)];
}
- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
NSLog(#"Device token is %#", deviceToken)
}
The message to register for notifications is displayed just one time, at the first installation. To change notifications settings, you can go in notifications settings.

Resources