Android how to show notification on screen

Create Notification using NotificationCompat.Builder NotificationCompat.Builder mBuilder = new NotificationCompat.Builder(this) .setSmallIcon(R.drawable.ic_launcher) // notification icon .setContentTitle(“Notification!”) // title for notification .setContentText(“Hello word”) // message for notification .setAutoCancel(true); // clear notification after click Intent intent = new Intent(this, MainActivity.class); PendingIntent pi = PendingIntent.getActivity(this,0,intent,Intent.FLAG_ACTIVITY_NEW_TASK); mBuilder.setContentIntent(pi); NotificationManager mNotificationManager = (NotificationManager) getSystemService(Context.NOTIFICATION_SERVICE); mNotificationManager.notify(0, mBuilder.build()); Push Notification on locked Screen http://www.hongkiat.com/blog/android-lock-screen-notifications/

How to access a Dictionary passed via NSNotification, using Swift

As notification.userInfo type is AnyObject ayou must downcast it to appropriate dictionary type. After exact type of dictionary is known you don’t need to downcast values you get from it. But you may want to check if values are actually present in dictionary before using them: // First try to cast user info to expected … Read more

How to use Notification.Name extension from Swift to Objective-C?

My extension in swift file extension Notification.Name { static let purchaseDidFinish = Notification.Name(“purchaseDidFinish”) } @objc extension NSNotification { public static let purchaseDidFinish = Notification.Name.purchaseDidFinish } // OBJECTIVE-C #import YourProjectName-Swift.h [NSNotificationCenter.defaultCenter addObserver:self selector:@selector(purchaseDidFinish) name:NSNotification.purchaseDidFinish object:nil]; // SWIFT NotificationCenter.default.addObserver(self, selector: #selector(purchaseDidFinish), name: .purchaseDidFinish, object: nil) @objc func purchaseDidFinish(notification: Notification) { print(“purchaseDidFinish”) } @leanne’s answer was super helpful

Notification to restore a task rather than a specific activity?

What you need is just a simple Activity that does nothing. Here is an example: public class NotificationActivity extends Activity { @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); // Now finish, which will drop the user in to the activity that was at the top // of the task stack finish(); } } Set up … Read more

iOS – Ask to enable push notifications after initial decline

You can’t make iOS show the alert again. Here’s a better approach: Keep a flag in your NSUserDefaults indicating whether you should register for push notifications at launch. By default the flag is false. When you launch, check the flag. If it’s true, register immediately. Otherwise, don’t register. The first time the user does something … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)