Flutter Deeplink Using OneSignal – AndroidCoding.in

Flutter Deeplinks :

Flutter deep connection strategy is defined in this site with OneSignal. Deep linking permits you to improve the user in flow to your apps, internet sites by earning them know the offered products and services.

You can customise the data with the help of photographs and 1 liners these that they draw in the user desire.

OneSignal supplies you numerous solutions applying which you can make the person re check out your application / website each individual time a new material is revealed or produced.

OneSignal makes use of the firebase as backend and gives you with the performance you can uncover firebase and its usages below firebase details.

 

pubspec.yaml:

We require to increase onesignal flutter dependency so that we can make use of onesignal expert services in our flutter application. Make guaranteed you give the most recent updates so that there are no challenges.

dependencies:
  flutter:
    sdk: flutter
  onesignal_flutter: ^3.5.

 

major.dart :

In this course file we are going to apply flutter deeplink onesignal.

import 'package:flutter/substance.dart'
import 'package:flutter_onesignal_deeplink/profile.dart'
import 'package:onesignal_flutter/onesignal_flutter.dart'

void key()
  runApp(MyApp())


class MyApp extends StatelessWidget 
  const MyApp(Crucial? key) : tremendous(important: key)

  @override
  Widget create(BuildContext context) 
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Textual content("Onesignal Deeplink"),
        ),
        entire body: Property()
      ),
    )
  



course Home extends StatefulWidget 
  const House(Critical? crucial) : tremendous(essential: crucial)

  @override
  State createState() => _HomeState()


course _HomeState extends Condition {

  @override
  void initState() 
    tremendous.initState()
    OneSignal.shared.setLogLevel(OSLogLevel.debug, OSLogLevel.none)
    OneSignal.shared.setAppId("82fc054e-08f0-4266-a9f5-d144716fcdae")

    OneSignal.shared.setNotificationOpenedHandler((openedResult) 
     var knowledge =  openedResult.notification.additionalData!["Page"].toString()
     
     if(knowledge == "Profile")
       Navigator.push(context, MaterialPageRoute(builder: (context) => Profile()))
     
     
    )
  

  @override
  Widget create(BuildContext context) 
    return Center(
      youngster: TextButton(
        little one: Textual content("House Display"),
        onPressed: ()
        ,
      ),
    )
  
}

 

profile.dart :

This is the profile display screen to which we are getting redirected once we get notification. In this article we are not supplying any further functionality.

import 'package:flutter/materials.dart'

class Profile extends StatelessWidget 
  const Profile(Vital? critical) : tremendous(essential: essential)

  @override
  Widget develop(BuildContext context) 
    return Scaffold(
      appBar: AppBar(title: const Textual content('Profile')),
      body: const Middle(
        child: Textual content("Profile Display",
          design and style: TextStyle(fontSize: 24.),
        ),
      ),
    )
  



Next Post

Chrissy Teigen Made John Legend Nostalgic On His Birthday 

John Legend turned 44 lately and his wife model and author Chrissy Teigen shared a heartwarming submit for him. Poured her heart out in the article. The couple has been by means of the worst and getting the ideal now. After shedding their baby in 2020, and afterwards conceiving via […]
Chrissy Teigen Made John Legend Nostalgic On His Birthday 

You May Like