Reputation: 707
I have implement push notifications in iOS7. As iOS7 having features of receiving push notification silently by using method
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo performFetchWithCompletionHandler:(void(^)(UIBackgroundFetchResult))completionHandler
{
}
But this method never getting called as I am sending notification. I am receiving the notification in notification tray But notification should not be there as It is silent. I am using Raywenderlich's PHP code to send the push Notification. I have added content-available key also like this
// Create the payload body
$body['aps'] = array(
'content-available' => '1',
'alert' => $message,
'sound' => 'default'
);
Please Help!!!
Upvotes: 0
Views: 2760
Reputation: 524
You should not add 'alert' param in your payload if you want to silent push notification.
pass your param like this.
$body['aps'] = array(
'content-available' => '1'
);
And verify you enabled remote-notification in your project plist.
or
You will get notification by implementing this delegate.
-(void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler{
// Call or write any code necessary to download new data.
completionHandler(UIBackgroundFetchResultNewData);
}
Upvotes: 3
Reputation: 6734
Try with a integer value :
$body['aps'] = array(
'content-available' => 1,
'alert' => $message,
'sound' => 'default'
);
Upvotes: 1