setLink

Sets a URL or deep link that will be opened when the user taps the notification.

This allows you to direct users to specific screens in your app or open external links in a browser.

  • HTTP/HTTPS URLs: Open in the default browser
  • Deep links: Navigate to specific app screens (e.g., "myapp://product/123")
  • If not set: Opens the default launcher activity
Example:

		  // Open a web page
		  LocalNotification webLink = new LocalNotification.Builder()
		      .setMessage("Check out our new collection!")
		      .setLink("https://example.com/new-collection")
		      .setDelay(3600)
		      .build();
		
		  // Navigate to specific product screen
		  LocalNotification productLink = new LocalNotification.Builder()
		      .setMessage("Your favorite item is back in stock!")
		      .setLink("myapp://products/12345")
		      .setDelay(7200)
		      .build();
		
		  // Navigate to cart screen
		  LocalNotification cartLink = new LocalNotification.Builder()
		      .setMessage("Complete your purchase - items in cart!")
		      .setLink("myapp://cart")
		      .setDelay(86400)
		      .build();
		
		  // Navigate to workout detail
		  LocalNotification workoutLink = new LocalNotification.Builder()
		      .setMessage("Time for today's workout")
		      .setLink("fitnessapp://workout/daily-routine")
		      .setDelay(3600)
		      .build();
		

Note: Make sure your app's deep link scheme is properly configured in AndroidManifest.xml to handle custom URL schemes.

Return

this builder instance for method chaining

Parameters

url

URL or deep link (e.g., "https://example.com" or "myapp://screen/id")

See also