Code Monkey home page Code Monkey logo

pichillilorenzo / flutter_appavailability Goto Github PK

View Code? Open in Web Editor NEW
91.0 91.0 88.0 143 KB

A Flutter plugin that allows you to check if an app is installed/enabled, launch an app and get the list of installed apps.

Home Page: https://pub.dartlang.org/packages/flutter_appavailability

License: MIT License

Java 31.32% Ruby 17.32% Swift 10.59% Objective-C 3.03% Dart 37.73%
android dart flutter flutter-package flutter-plugin ios plugin swift

flutter_appavailability's Introduction

Hi πŸ‘‹, I'm Lorenzo Pichilli

A Heroku Architecture Designer and a Software Engineer mostly focused on Web (Full Stack) and Mobile Development. JavaScript, TypeScript & Flutter enthusiast πŸ’™.

pichillilorenzo

Latest Blog posts

Connect with me:

lorenzopichilli lorenzo-pichilli 4637638 lorenzopichilli @pichillilorenzo

Β pichillilorenzo

Support me and my projects

Donate with PayPal

flutter_appavailability's People

Contributors

pichillilorenzo avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

flutter_appavailability's Issues

IOS Build Failed

Trying this package at IOS and getting this error using the example code:

** BUILD FAILED **
Xcode's output:
↳
=== BUILD TARGET flutter_appavailability OF PROJECT Pods WITH CONFIGURATION Debug ===
/Users/rodrigoavelino/Dev/flutter/.pub-cache/hosted/pub.dartlang.org/flutter_appavailability-0.0.21/ios/Classes/AppAvailability.m:2:9: fatal error: 'flutter_appavailability/flutter_appavailability-Swift.h' file not found
#import <flutter_appavailability/flutter_appavailability-Swift.h>
^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
1 error generated.

my flutter doctor

Doctor summary (to see all details, run flutter doctor -v):
[βœ“] Flutter (Channel stable, v1.0.0, on Mac OS X 10.13.6 17G4015, locale pt-BR)
[βœ“] Android toolchain - develop for Android devices (Android SDK 28.0.3)
[βœ“] iOS toolchain - develop for iOS devices (Xcode 10.1)
[βœ“] Android Studio (version 3.2)
[βœ“] IntelliJ IDEA Community Edition (version 2018.3)
[βœ“] VS Code (version 1.30.0)
[βœ“] Connected device (1 available)

my Podfile

#Uncomment this line to define a global platform for your project
#platform :ios, '9.0'

#CocoaPods analytics sends network stats synchronously affecting flutter build latency.
ENV['COCOAPODS_DISABLE_STATS'] = 'true'

project 'Runner', {
'Debug' => :debug,
'Profile' => :release,
'Release' => :release,
}

def parse_KV_file(file, separator='=')
file_abs_path = File.expand_path(file)
if !File.exists? file_abs_path
return [];
end
pods_ary = []
skip_line_start_symbols = ["#", "/"]
File.foreach(file_abs_path) { |line|
next if skip_line_start_symbols.any? { |symbol| line =~ /^\s*#{symbol}/ }
plugin = line.split(pattern=separator)
if plugin.length == 2
podname = plugin[0].strip()
path = plugin[1].strip()
podpath = File.expand_path("#{path}", file_abs_path)
pods_ary.push({:name => podname, :path => podpath});
else
puts "Invalid plugin specification: #{line}"
end
}
return pods_ary
end

target 'Runner' do
#Prepare symlinks folder. We use symlinks to avoid having Podfile.lock
#referring to absolute paths on developers' machines.
system('rm -rf .symlinks')
system('mkdir -p .symlinks/plugins')

#Flutter Pods
generated_xcode_build_settings = parse_KV_file('./Flutter/Generated.xcconfig')
if generated_xcode_build_settings.empty?
puts "Generated.xcconfig must exist. If you're running pod install manually, make sure flutter packages get is executed first."
end
generated_xcode_build_settings.map { |p|
if p[:name] == 'FLUTTER_FRAMEWORK_DIR'
symlink = File.join('.symlinks', 'flutter')
File.symlink(File.dirname(p[:path]), symlink)
pod 'Flutter', :path => File.join(symlink, File.basename(p[:path]))
end
}

#Plugin Pods
plugin_pods = parse_KV_file('../.flutter-plugins')
plugin_pods.map { |p|
symlink = File.join('.symlinks', 'plugins', p[:name])
File.symlink(p[:path], symlink)
pod p[:name], :path => File.join(symlink, 'ios')
}
end

post_install do |installer|
installer.pods_project.targets.each do |target|
target.build_configurations.each do |config|
config.build_settings['ENABLE_BITCODE'] = 'NO'
end
end
end

my pubspec.yaml

name: plugin_flutter_availability
description: A new Flutter project.

#The following defines the version and build number for your application.
#A version number is three numbers separated by dots, like 1.2.43
#followed by an optional build number separated by a +.
#Both the version and the builder number may be overridden in flutter
#build by specifying --build-name and --build-number, respectively.
#Read more about versioning at semver.org.
version: 1.0.0+1

environment:
sdk: ">=2.0.0-dev.68.0 <3.0.0"

dependencies:
flutter:
sdk: flutter
flutter_appavailability: ^0.0.21

#The following adds the Cupertino Icons font to your application.
#Use with the CupertinoIcons class for iOS style icons.
cupertino_icons: ^0.1.2

dev_dependencies:
flutter_test:
sdk: flutter

#For information on the generic Dart part of this file, see the
#following page: https://www.dartlang.org/tools/pub/pubspec

#The following section is specific to Flutter.
flutter:

#The following line ensures that the Material Icons font is
#included with your application, so that you can use the icons in
#the material Icons class.
uses-material-design: true

#To add assets to your application, add an assets section, like this:
#assets:
#- images/a_dot_burr.jpeg
#- images/a_dot_ham.jpeg

#An image asset can refer to one or more resolution-specific "variants", see
#https://flutter.io/assets-and-images/#resolution-aware.

#For details regarding adding assets from package dependencies, see
#https://flutter.io/assets-and-images/#from-packages

#To add custom fonts to your application, add a fonts section here,
#in this "flutter" section. Each entry in this list should have a
#"family" key with the font family name, and a "fonts" key with a
#list giving the asset and other descriptors for the font. For
#example:
#fonts:
#- family: Schyler
#fonts:
#- asset: fonts/Schyler-Regular.ttf
#- asset: fonts/Schyler-Italic.ttf
#style: italic
#- family: Trajan Pro
#fonts:
#- asset: fonts/TrajanPro.ttf
#- asset: fonts/TrajanPro_Bold.ttf
#weight: 700

#For details regarding fonts from package dependencies,
#see https://flutter.io/custom-fonts/#from-packages

Update compileSdkVersion 27 to 28

flutter_appavailability/android/build.gradle:line 25
compileSdkVersion 27

Would it be ok to update to 28?

All my Flutter plugins have compileSdkVersion 28 in their respective build.gradle files.
When generating my Android release build it fails, but succeeds when I manually edit line 25 above to use 28.

Crash when using with Android embedding V2

We have upgraded our app to support Android Embedding V2. The app attempts to launch and then immediately crashes:

2021-05-07 14:53:51.474 9171-9171/org.my.app E/MethodChannel#: Parameter messenger must not be null.
2021-05-07 14:53:51.474 9171-9171/org.my.app D/AndroidRuntime: Shutting down VM
2021-05-07 14:53:51.480 9171-9171/org.my.app E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.my.app, PID: 9171
java.lang.NullPointerException: Attempt to invoke interface method 'void io.flutter.plugin.common.BinaryMessenger.setMessageHandler(java.lang.String, io.flutter.plugin.common.BinaryMessenger$BinaryMessageHandler)' on a null object reference
at io.flutter.plugin.common.MethodChannel.setMethodCallHandler(MethodChannel.java:119)
at com.pichillilorenzo.flutter_appavailability.AppAvailability.registerWith(AppAvailability.java:37)
at io.flutter.plugins.GeneratedPluginRegistrant.registerWith(GeneratedPluginRegistrant.java:24)
at org.my.app.MainActivity.configureFlutterEngine(MainActivity.kt:54)
at io.flutter.embedding.android.FlutterFragment.configureFlutterEngine(FlutterFragment.java:1016)
at io.flutter.embedding.android.FlutterActivityAndFragmentDelegate.onAttach(FlutterActivityAndFragmentDelegate.java:180)
at io.flutter.embedding.android.FlutterFragment.onAttach(FlutterFragment.java:608)
at androidx.fragment.app.Fragment.performAttach(Fragment.java:2672)
at androidx.fragment.app.FragmentStateManager.attach(FragmentStateManager.java:253)
at androidx.fragment.app.FragmentManager.moveToState(FragmentManager.java:1168)
at androidx.fragment.app.FragmentTransition.addToFirstInLastOut(FragmentTransition.java:1255)
at androidx.fragment.app.FragmentTransition.calculateFragments(FragmentTransition.java:1138)
at androidx.fragment.app.FragmentTransition.startTransitions(FragmentTransition.java:136)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1987)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:1945)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:1847)
at androidx.fragment.app.FragmentManager.dispatchStateChange(FragmentManager.java:2621)
at androidx.fragment.app.FragmentManager.dispatchActivityCreated(FragmentManager.java:2569)
at androidx.fragment.app.FragmentController.dispatchActivityCreated(FragmentController.java:247)
at androidx.fragment.app.FragmentActivity.onStart(FragmentActivity.java:541)
at org.my.app.MainActivity.onStart(MainActivity.kt:178)
at android.app.Instrumentation.callActivityOnStart(Instrumentation.java:1413)
at android.app.Activity.performStart(Activity.java:7169)
at android.app.ActivityThread.handleStartActivity(ActivityThread.java:3155)
at android.app.servertransaction.TransactionExecutor.performLifecycleSequence(TransactionExecutor.java:180)
at android.app.servertransaction.TransactionExecutor.cycleToPath(TransactionExecutor.java:165)
at android.app.servertransaction.TransactionExecutor.executeLifecycleState(TransactionExecutor.java:142)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:70)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1986)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:215)
at android.app.ActivityThread.main(ActivityThread.java:6939)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:870)

Can't open my app from background

I am trying to implement alarm clock, using alarm manager and this package, but it gives me this message, when i trying to launch app from background:

E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): Failed to handle method call
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at com.pichillilorenzo.flutter_appavailability.AppAvailability.getAppPackageInfo(AppAvailability.java:93)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at com.pichillilorenzo.flutter_appavailability.AppAvailability.launchApp(AppAvailability.java:131)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at com.pichillilorenzo.flutter_appavailability.AppAvailability.onMethodCall(AppAvailability.java:57)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at android.os.MessageQueue.next(MessageQueue.java:335)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at android.os.Looper.loop(Looper.java:183)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at android.app.ActivityThread.main(ActivityThread.java:7656)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at java.lang.reflect.Method.invoke(Native Method)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
E/MethodChannel#com.pichillilorenzo/flutter_appavailability( 4567): 	at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
E/flutter ( 4567): [ERROR:flutter/lib/ui/ui_dart_state.cc(199)] Unhandled Exception: PlatformException(error, Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference, null, java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.Context android.app.Activity.getApplicationContext()' on a null object reference
E/flutter ( 4567): 	at com.pichillilorenzo.flutter_appavailability.AppAvailability.getAppPackageInfo(AppAvailability.java:93)
E/flutter ( 4567): 	at com.pichillilorenzo.flutter_appavailability.AppAvailability.launchApp(AppAvailability.java:131)
E/flutter ( 4567): 	at com.pichillilorenzo.flutter_appavailability.AppAvailability.onMethodCall(AppAvailability.java:57)
E/flutter ( 4567): 	at io.flutter.plugin.common.MethodChannel$IncomingMethodCallHandler.onMessage(MethodChannel.java:233)
E/flutter ( 4567): 	at io.flutter.embedding.engine.dart.DartMessenger.handleMessageFromDart(DartMessenger.java:85)
E/flutter ( 4567): 	at io.flutter.embedding.engine.FlutterJNI.handlePlatformMessage(FlutterJNI.java:818)
E/flutter ( 4567): 	at android.os.MessageQueue.nativePollOnce(Native Method)
E/flutter ( 4567): 	at android.os.MessageQueue.next(MessageQueue.java:335)
E/flutter ( 4567): 	at android.os.Looper.loop(Looper.java:183)
E/flutter ( 4567): 	at android.app.ActivityThread.main(ActivityThread.java:7656)

`flutter_appavailability` does not specify a Swift version

When trying to build the app in xCode I receive the following error:

[!] Unable to determine Swift version for the following pods:
- flutter_appavailability does not specify a Swift version and none of the targets (Runner) integrating it have the SWIFT_VERSION attribute set. Please contact the author or set the SWIFT_VERSION attribute in at least one of the targets that integrate this pod.

app icons

is it possible to get the app icon path if an application is found? Also, how did you get the package_name key for ios?

Doesn't work on iOS

I tried to use this package to launch an app on iOS, but it doesn't work. The only app it will open from the demo is calshow://. Whatsapp, Facebook and the app I wanted to open don't work.
Also the checkAvailability doesn't work for them.

On Android it works fine.

deprecated version of the Android embedding

After upgrading Flutter to version 2.5.0 I get the following warning.

The plugin `flutter_appavailability` uses a deprecated version of the Android embedding.
To avoid unexpected runtime failures, or future build failures, try to see if this plugin supports the Android V2 embedding. Otherwise, consider removing it since a future release of Flutter will remove these deprecated APIs.
If you are plugin author, take a look at the docs for migrating the plugin to the V2 embedding: https://flutter.dev/go/android-plugin-migration.

Could you please updated this plugin?

App not found IOS

I am launching a flutter app (App 1) from another flutter app (App 2) on Android and it works perfectly. However, I keep getting the same error on IOS. It does not recognize the package name.

I have tried with multiple apps but is the same result, it currently just recognizes the calendar package.

pubspec.yaml file flutter_appavailability

main.dart App 2

import 'package:flutter_appavailability/flutter_appavailability.dart';

//Future void method
if (Platform.isIOS) {

_installedApps = [
        {"app_name": "example", "package_name": "com.flutter.example"},
      ];

      print(await AppAvailability.checkAvailability("com.flutter.example")); //ERROR

 //Widget build
return Container {
 child : Row(
   ...
   GestureDetector(
    ...
    onTap: () {
              Scaffold.of(context).hideCurrentSnackBar();
              AppAvailability.launchApp(installedApps[0].["package_name"])
                  .then((_) {
                print("App ${installedApps[0]["app_name"]} launched!");
              }).catchError((err) {
                Scaffold.of(context).showSnackBar(SnackBar(
                    content: Text(
                        "App ${installedApps[0]["app_name"]} not found!")));
                print(err);
      });
...
 ),
}

info.plist App 1

<key>CFBundleIdentifier</key>
	<string>$(PRODUCT_BUNDLE_IDENTIFIER)</string>

project.pbxproj App 1
PRODUCT_BUNDLE_IDENTIFIER = com.flutter.example;

Output App 2

[VERBOSE-2:ui_dart_state.cc(148)] Unhandled Exception: PlatformException(, App not found com.flutter.example, null)
#0      AppAvailability.checkAvailability (package:flutter_appavailability/flutter_appavailability.dart:40:9)

recent apps?

any chance this package could implement a method to get apps that have been used most recently?

No implementation found for method launch app/checkAvailability

hi @pichillilorenzo
I have just started to make an app iOS compatible and it seems that what has worked fine on Android is causing problems on iOS.

I tried to check the app 'calshow://', here's the exception for one of the calls:

#0      MethodChannel.invokeMethod (package:flutter/src/services/platform_channel.dart:314:7)
<asynchronous suspension>
#1      AppAvailability.checkAvailability (package:flutter_appavailability/flutter_appavailability.dart:38:42)

Thanks for your work, it's amazingly smooth on Android!

Open apps with parameter

I'm using this plugin, and work perfectly when I open other apps without parameter. Now I'm building 2 flutter apps, in first apps, I want to click button then open 2nd apps but with parameter, like to tell 2nd app to open specific page or to show some message. Can this handled by this plugin? thanks

cannot open instagram , youtube , twitter in ios

hi
i tried to open instagram,youtube,twitter
via "instagram://" and "instagram-stories://"

see :https://pureoxygenlabs.com/10-app-url-schemes-for-marketers/
and i failed the only working solution is
'whatsapp://'

any help

flutter version : Flutter 1.22.3 β€’ channel stable
phone : iphone 5s running ios 12.5.1
`[βœ“] Flutter (Channel stable, 1.22.3, on Mac OS X 10.14.6 18G7016, locale en-EG)

[βœ“] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
[βœ“] Xcode - develop for iOS and macOS (Xcode 11.3.1)
[βœ“] Android Studio (version 3.6)
[βœ“] VS Code (version 1.52.1)
[βœ“] Connected device (1 available)

β€’ No issues found!`
any help with ios

Unable to build release

When running on release mode, I get a build error:

FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':flutter_appavailability:verifyReleaseResources'.
> java.util.concurrent.ExecutionException: com.android.builder.internal.aapt.v2.Aapt2Exception: Android resource linking failed
  C:\Users\hugoc\IdeaProjects\Flutter\buster\build\flutter_appavailability\intermediates\res\merged\release\values\values.xml:236: error: resource android:attr/fontVariationSettings not found.
  C:\Users\hugoc\IdeaProjects\Flutter\buster\build\flutter_appavailability\intermediates\res\merged\release\values\values.xml:237: error: resource android:attr/ttcIndex not found.
  error: failed linking references.

This error can be reproduced in any project. Just add the dependency and try to run on release mode or build an apk/app-bundle.

Don't know whether iOS has been affected, since I just tested on Android.

I started to encounter this error as soon as I updated Flutter to v1.12.13+hotfix.5. Previously, I was using Flutter v1.9.1+hotfix.6.

Migrate TO null safety

don't support null safety:

  • package:flutter_appavailability

please migrate to null safety

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.