Is it possible to pop up local notifications while the iphone app is on screen?

后端 未结 3 1443
礼貌的吻别
礼貌的吻别 2021-01-04 23:40

I need a local notification for an iphone app to pop up while the app is active. Is this possible? If so how?

相关标签:
3条回答
  • 2021-01-05 00:19

    Local notifications and push notifications are ways for an application that isn’t running in the foreground to let its users know it has information for them. The information could be a message, an impending calendar event, or new data on a remote server. When presented by the operating system, local and push notifications look and sound the same. They can display an alert message or they can badge the application icon. They can also play a sound when the alert or badge number is shown.For detail knowledge see this link Local Notification

    0 讨论(0)
  • 2021-01-05 00:23

    You can make a same animation in app.

    I made a lib to make an animation almost as same as local notification's.

    Check this: https://github.com/OpenFibers/OTNotification

    Demo: enter image description here

    enter image description here

    And you can post a new message to this lib when you received a message in

    - (void) application:(UIApplication *)application didReceiveLocalNotification:    (UILocalNotification *)notification
    {
        OTNotificationManager *notificationManager = [OTNotificationManager defaultManager];
        OTNotificationMessage *notificationMessage = [[OTNotificationMessage alloc] init];
        notificationMessage.title = [self notificationTitle];
        notificationMessage.message = @"A notification. Touch me to hide me.";
        [notificationManager postNotificationMessage:notificationMessage];
    }
    
    0 讨论(0)
  • 2021-01-05 00:26
    - (void)application:(UIApplication *)application didReceiveLocalNotification:(UILocalNotification *)notification
    

    is called if you have a notification scheduled and the app is already running..it is a UIApplication delegate method..

    here you can do your custom code..by accessing the notification...

    edit :

    if you want to present a notification right now .. then you can just set the notification fire date to past...it will be fired..then you can create a alert view in the above given UIapplication method

    0 讨论(0)
提交回复
热议问题