Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

RCTPushNotificationManager does not set alertTitle in UILocalNotification #14699

Closed
stage88 opened this issue Jun 23, 2017 · 5 comments
Closed
Labels
Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Resolution: Locked This issue was locked by the bot.

Comments

@stage88
Copy link

stage88 commented Jun 23, 2017

Description

Setting the alertTitle property on PushNotificationIOS.scheduleLocalNotification does not display the title in the notification.

With alertTitle set:
image

Without:
image

Reproduction Steps

Use the below code to reproduce.

Sample Code

PushNotificationIOS.scheduleLocalNotification({ fireDate: new Date(Date.now() + (30 * 1000)).toISOString(), alertTitle: 'Incoming Message', alertBody: 'This is my message, please read it for good fortune.', soundName: 'default', applicationIconBadgeNumber: 1, userInfo: { id: 11 } })

Solution

Adding the following line in RCTPushNotificationManager.m (54) fixes the issue:

notification.alertTitle = [RCTConvert NSString:details[@"alertTitle"]];

Additional Information

  • React Native version: 0.45
  • Platform: iOS
  • Development Operating System: macOS Sierra 10.12.15
  • Build tools: XCode 8.3.3
@hramos
Copy link
Contributor

hramos commented Jun 23, 2017

Can you send a PR?

@hramos hramos added the Good first issue Interested in collaborating? Take a stab at fixing one of these issues. label Aug 4, 2017
@hramos
Copy link
Contributor

hramos commented Aug 4, 2017

Tagging as a Good First Task. A solution is provided in the original post above. People can get familiar with the contribution process by applying the fix in a PR.

@tinajohnson
Copy link

@hramos I'm ready to create a PR as I'm new to the contribution process and is essential for me to get to know the process.

facebook-github-bot pushed a commit that referenced this issue Aug 7, 2017
Summary:
Currently, since the alertTitle is not set in UILocalNotification, the notification displays just the notification body with no title. This commit sets the alertTitle for local notifications.

Issue: #14699

- In a sample RN app, created a component and added the following code to componentDidMount():
`PushNotificationIOS.scheduleLocalNotification({
     fireDate: new Date(Date.now() + (30 * 1000)).toISOString(),
     alertTitle: 'Incoming Message',
     alertBody: 'Test message',
     soundName: 'default'
 })`

- On running the app, the notification appears with both body and title once the component is mounted.

![settitle_fix](https://user-images.githubusercontent.com/4279549/28995873-f62c9866-7a11-11e7-9f29-95dba50ef40b.jpg)
Closes #15381

Differential Revision: D5572606

Pulled By: shergin

fbshipit-source-id: ce5d98ed595eedf51ac3da7dfd94de52cf80be3d
@stage88
Copy link
Author

stage88 commented Dec 6, 2017

Great work on this guys, thanks!

@stage88 stage88 closed this as completed Dec 6, 2017
@facebook facebook locked as resolved and limited conversation to collaborators Dec 6, 2018
@react-native-bot react-native-bot added the Resolution: Locked This issue was locked by the bot. label Dec 6, 2018
@cpojer
Copy link
Contributor

cpojer commented Feb 13, 2019

This issue has been moved to react-native-push-notification/ios#2.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Good first issue Interested in collaborating? Take a stab at fixing one of these issues. Resolution: Locked This issue was locked by the bot.
Projects
None yet
Development

No branches or pull requests

5 participants