├── .eslintrc.js ├── .github └── workflows │ └── npm.yml ├── .gitignore ├── .npmignore ├── CHANGELOG.md ├── LICENSE ├── README.md ├── app.plugin.js ├── example ├── .gitignore ├── App.tsx ├── app.json ├── assets │ ├── adaptive-icon.png │ ├── favicon.png │ ├── icon.png │ └── splash.png ├── babel.config.js ├── index.js ├── ios │ ├── .gitignore │ ├── .xcode.env │ ├── Podfile │ ├── Podfile.lock │ ├── Podfile.properties.json │ ├── exposhazamkitexample.xcodeproj │ │ ├── project.pbxproj │ │ └── xcshareddata │ │ │ └── xcschemes │ │ │ └── exposhazamkitexample.xcscheme │ ├── exposhazamkitexample.xcworkspace │ │ ├── contents.xcworkspacedata │ │ └── xcshareddata │ │ │ └── IDEWorkspaceChecks.plist │ └── exposhazamkitexample │ │ ├── AppDelegate.h │ │ ├── AppDelegate.mm │ │ ├── Images.xcassets │ │ ├── AppIcon.appiconset │ │ │ ├── App-Icon-1024x1024@1x.png │ │ │ └── Contents.json │ │ ├── Contents.json │ │ ├── SplashScreen.imageset │ │ │ ├── Contents.json │ │ │ └── image.png │ │ └── SplashScreenBackground.imageset │ │ │ ├── Contents.json │ │ │ └── image.png │ │ ├── Info.plist │ │ ├── SplashScreen.storyboard │ │ ├── Supporting │ │ └── Expo.plist │ │ ├── exposhazamkitexample-Bridging-Header.h │ │ ├── exposhazamkitexample.entitlements │ │ ├── main.m │ │ └── noop-file.swift ├── metro.config.js ├── package-lock.json ├── package.json └── tsconfig.json ├── expo-module.config.json ├── ios ├── MatchedItem.swift ├── ShazamDelegate.swift ├── ShazamExceptions.swift ├── ShazamKitModule.podspec └── ShazamKitModule.swift ├── package-lock.json ├── package.json ├── plugin ├── src │ └── withShazamKit.ts └── tsconfig.json ├── src ├── ExpoShazamKit.ts ├── ExpoShazamKit.types.ts └── index.ts └── tsconfig.json /.eslintrc.js: -------------------------------------------------------------------------------- 1 | module.exports = { 2 | root: true, 3 | extends: ["universe/native"], 4 | ignorePatterns: ["build"], 5 | }; 6 | -------------------------------------------------------------------------------- /.github/workflows/npm.yml: -------------------------------------------------------------------------------- 1 | name: Publish package 2 | 3 | on: 4 | release: 5 | types: [published] 6 | 7 | jobs: 8 | build: 9 | runs-on: ubuntu-latest 10 | steps: 11 | - uses: actions/checkout@v3 12 | - uses: actions/setup-node@v3 13 | with: 14 | node-version: "16.x" 15 | registry-url: "https://registry.npmjs.org" 16 | - run: yarn install 17 | - run: yarn build 18 | - run: npm publish 19 | env: 20 | NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} 21 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # OSX 2 | # 3 | .DS_Store 4 | 5 | # VSCode 6 | .vscode/ 7 | jsconfig.json 8 | 9 | # Xcode 10 | # 11 | build/ 12 | *.pbxuser 13 | !default.pbxuser 14 | *.mode1v3 15 | !default.mode1v3 16 | *.mode2v3 17 | !default.mode2v3 18 | *.perspectivev3 19 | !default.perspectivev3 20 | xcuserdata 21 | *.xccheckout 22 | *.moved-aside 23 | DerivedData 24 | *.hmap 25 | *.ipa 26 | *.xcuserstate 27 | project.xcworkspace 28 | 29 | # Android/IJ 30 | # 31 | .classpath 32 | .cxx 33 | .gradle 34 | .idea 35 | .project 36 | .settings 37 | local.properties 38 | android.iml 39 | 40 | # Cocoapods 41 | # 42 | example/ios/Pods 43 | 44 | # Ruby 45 | example/vendor/ 46 | 47 | # node.js 48 | # 49 | node_modules/ 50 | npm-debug.log 51 | yarn-debug.log 52 | yarn-error.log 53 | 54 | # BUCK 55 | buck-out/ 56 | \.buckd/ 57 | android/app/libs 58 | android/keystores/debug.keystore 59 | 60 | # Expo 61 | .expo/* 62 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | # Exclude all top-level hidden directories by convention 2 | /.*/ 3 | 4 | __mocks__ 5 | __tests__ 6 | 7 | /babel.config.js 8 | /android/src/androidTest/ 9 | /android/src/test/ 10 | /android/build/ 11 | /example/ 12 | -------------------------------------------------------------------------------- /CHANGELOG.md: -------------------------------------------------------------------------------- 1 | # Changelog 2 | 3 | All notable changes to this project will be documented in this file. 4 | 5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), 6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). 7 | 8 | ## [Unreleased] 9 | 10 | ### Added 11 | 12 | - Changelog 13 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | MIT License 2 | 3 | Copyright (c) 2023 Alan Hughes 4 | 5 | Permission is hereby granted, free of charge, to any person obtaining a copy 6 | of this software and associated documentation files (the "Software"), to deal 7 | in the Software without restriction, including without limitation the rights 8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 9 | copies of the Software, and to permit persons to whom the Software is 10 | furnished to do so, subject to the following conditions: 11 | 12 | The above copyright notice and this permission notice shall be included in all 13 | copies or substantial portions of the Software. 14 | 15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 21 | SOFTWARE. 22 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Expo Shazamkit 2 | 3 | Shazam for React Native 4 | 5 | ## Preview 6 | 7 | https://user-images.githubusercontent.com/30924086/229935589-ef3e60ae-10f0-4e0d-aebf-a0ce06d8dba2.mov 8 | 9 | # Installation 10 | 11 | ```sh 12 | npx expo install expo-shazamkit 13 | ``` 14 | 15 | For bare React Native projects, you must ensure that you have [installed and configured the `expo` package](https://docs.expo.dev/bare/installing-expo-modules/) before continuing. 16 | 17 | ## Configuration for iOS 🍏 18 | 19 | > This is only required for usage in bare React Native apps. 20 | 21 | Run `npx pod-install` after installing the npm package. 22 | 23 | Add the following to your `Info.plist`: 24 | 25 | ```xml 26 | NSMicrophoneUsageDescription 27 | $(PRODUCT_NAME) would like to access your microphone 28 | ``` 29 | 30 | ShazmamKit is only available on iOS 15.0 and above. You'll need to set your deployment target to iOS 15.0 or above. 31 | 32 | ## Activate the ShazamKit service 33 | 34 | On your apple developer account page, under `Certificates, Identifiers & Profiles` select `Identifiers`. If you have already created an identifier for your app, select it. If not, create a new one. Under `App Services` enable `ShazamKit`. 35 | 36 | ### Plugin 37 | 38 | You need to request access to the microphone to record audio. You can use the plugin to set the message you would like or use the default `Allow $(PRODUCT_NAME) to access your microphone`. 39 | 40 | Also, you will need to set the deployment target to iOS 15.0 or above. You can do this by installing `expo-build-properties` 41 | 42 | `app.json` 43 | 44 | ```json 45 | { 46 | "plugins": [ 47 | [ 48 | "expo-shazamkit", 49 | { 50 | "microphonePermission": "Your permission message" 51 | } 52 | ], 53 | [ 54 | "expo-build-properties", 55 | { 56 | "ios": { 57 | "deploymentTarget": "15.0" 58 | } 59 | } 60 | ] 61 | ] 62 | } 63 | ``` 64 | 65 | ## Usage 66 | 67 | ```ts 68 | import * as Linking from "expo-linking"; 69 | import * as ExpoShazamKit from "expo-shazamkit"; 70 | 71 | // ... 72 | const [searching, setSearching] = useState(false); 73 | const [song, setSong] = useState(null); 74 | 75 | const startListening = async () => { 76 | try { 77 | if (song) { 78 | setSong(null); 79 | } 80 | 81 | setSearching(true); 82 | const result = await ExpoShazamKit.startListening(); 83 | if (result.length > 0) { 84 | setSong(result[0]); 85 | } else { 86 | Alert.alert("No Match", "No songs found"); 87 | } 88 | 89 | setSearching(false); 90 | } catch (error: any) { 91 | if (error instanceof Error) { 92 | Alert.alert("Error", error.message); 93 | } 94 | setSearching(false); 95 | } 96 | }; 97 | 98 | 99 | {song && ( 100 | 101 | 108 | 109 | {song.title} 110 | 111 | {song.artist} 112 | 113 | 114 | 115 |