{"id":19542144,"url":"https://github.com/thomasgazzoni/ng2-platform","last_synced_at":"2025-04-26T17:31:11.590Z","repository":{"id":94135237,"uuid":"75583363","full_name":"thomasgazzoni/ng2-platform","owner":"thomasgazzoni","description":"Cross platforms (Browser, Mobile and Desktop) feature with Angular2, Ionic2 and Electron","archived":false,"fork":false,"pushed_at":"2017-04-02T09:32:57.000Z","size":80,"stargazers_count":7,"open_issues_count":0,"forks_count":0,"subscribers_count":4,"default_branch":"master","last_synced_at":"2024-05-01T14:47:23.623Z","etag":null,"topics":["angular","electron","ionic2","rxjs"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/thomasgazzoni.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2016-12-05T03:02:00.000Z","updated_at":"2018-02-11T01:27:41.000Z","dependencies_parsed_at":"2023-03-12T03:16:42.001Z","dependency_job_id":null,"html_url":"https://github.com/thomasgazzoni/ng2-platform","commit_stats":{"total_commits":35,"total_committers":2,"mean_commits":17.5,"dds":0.05714285714285716,"last_synced_commit":"574db6326aa178eb0a2e49a417d5eb435d60a3c5"},"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasgazzoni%2Fng2-platform","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasgazzoni%2Fng2-platform/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasgazzoni%2Fng2-platform/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/thomasgazzoni%2Fng2-platform/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/thomasgazzoni","download_url":"https://codeload.github.com/thomasgazzoni/ng2-platform/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":251025707,"owners_count":21524843,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["angular","electron","ionic2","rxjs"],"created_at":"2024-11-11T03:13:24.804Z","updated_at":"2025-04-26T17:31:11.584Z","avatar_url":"https://github.com/thomasgazzoni.png","language":"TypeScript","readme":"[![Build Status](https://travis-ci.org/thomasgazzoni/ng2-platform.svg?branch=master)](https://travis-ci.org/thomasgazzoni/ng2-platform)\n[![npm version](https://badge.fury.io/js/ng2-platform.svg)](https://badge.fury.io/js/ng2-platform)\n[![npm](https://img.shields.io/npm/dm/ng2-platform.svg)](https://www.npmjs.com/package/ng2-platform)\n[![bitHound Overall Score](https://www.bithound.io/github/thomasgazzoni/ng2-platform/badges/score.svg)](https://www.bithound.io/github/thomasgazzoni/ng2-platform)\n[![bitHound Dependencies](https://www.bithound.io/github/thomasgazzoni/ng2-platform/badges/dependencies.svg)](https://www.bithound.io/github/thomasgazzoni/ng2-platform/master/dependencies/npm)\n[![bitHound Code](https://www.bithound.io/github/thomasgazzoni/ng2-platform/badges/code.svg)](https://www.bithound.io/github/thomasgazzoni/ng2-platform)\n\n# ng2-platform\n\nThe aim of this project is provide a cross platforms access to native feature available on Browser, Mobile (Ionic 2) and Desktop (Electron).\nEach Feature will espose methods with RxJs Observable making their api agnostic among various platform.\n\n| Feature | Description | Browser | Ionic2 | Electron |\n| --- | --- | --- | --- | --- |\n| `Analytics` | Send Google Analytics | Available | Available | Available\n| `Camera` | Take or select picture | Available (only take photo) | Available | TODO\n| `Clipboard` | Copy and Paste | Available | Available | Available\n| `Download` | Download file in backgroud | Need improve | TODO | TODO\n| `Location` | Get current GPS position | Available | Available | Available\n| `Push` | Push notification | Available (with SW) | Available | TODO\n| `Qrcode` | Generate and scan QR Code | TODO | Available | TODO\n| `Share` | Share link on social network | Available (Chrome Origin Trials) | Available | TODO\n| `Upload` | Upload a file | Available | Available | TODO\n| `Storage` | Localstorage for caching | Available | Available | TODO\n| `Core` | Platform service | Available | Available | Available\n\n## Project status\nThis project is just started, I am looking for collaborators to expand the Electron's features (although the implementation will be same as the Browser for most of the cases)\nsince are not fully implemented/tested at this moment.\nI will use as much as possible native api for the Browser platform this means that things will works only in latest browsers version.\nNOTE: the code is not yet optimize but it works in most of the case, if doesn't work in your use case just open an issues I will be eager to look into it!\n\n## Install\n```sh\nnpm install ng2-platform\n```\n\nFor Ionic 2 use case, for each feature you will going to use in your project, you must add the correspondent cordova plugin:\n```sh\nionic plugin add cordova-plugin-device\nionic plugin add phonegap-plugin-push --variable SENDER_ID=\"1234567890\"\nionic plugin add phonegap-plugin-barcodescanner\nionic plugin add cordova-plugin-x-socialsharing\nionic plugin add cordova-plugin-camera\nionic plugin add cordova-plugin-geolocation\nionic plugin add cordova-plugin-file\nionic plugin add cordova-plugin-file-transfer\nionic plugin add cordova-plugin-google-analytics\n```\n\n## How it works\nEach Feature have a:\n - **XxxService**: containing the abstract feature declaration (with options and result interface)\n - **factoryXxxService**: factory function to create the right instace of the service base on the platform.\n - **XxxServiceXxxplatform**: native implementation for each platform (foo.browser.ts, foo.ionic.ts, foo.electron.ts, etc)\n\n## Exemple\n\n - In your app main module\n```ts\n// app.module.ts\nimport { Ng2PlatformModule } from 'ng2-platform';\n...\n\n@NgModule({\n    ...\n    imports: [\n        ... // your modules\n        Ng2PlatformModule.forRoot({\n            appName: 'MyAppName',\n            appVersion: '1.0',\n            FCMSenderId: '1234567890',\n        }),\n    ]\n    ...\n})\nexport class AppModule ...\n```\n\n - Example for take a picture using the PC/Laptop Camera and upload it to some API\n```ts\n// user-profile.component.ts\nimport { Component } from '@angular/core';\nimport { Observable } from 'rxjs/Observable';\nimport { CameraService, UploadService } from 'ng2-platform';\n...\n\n@Component({\n    selector: 'us-user-profile',\n    templateUrl: 'user-profile.component.html',\n    changeDetection: ChangeDetectionStrategy.Default\n})\nexport class UserProfileComponent implements OnInit {\n\n    constructor(\n        private _uploadService: UploadService,\n        private _cameraService: CameraService,\n    ) {\n\n    }\n\n    ngOnInit() {\n        // If the upload API need some custom headers you can set it before call the upload method\n        this._uploadService.setApiHeaders({\n            'X-CSRFToken': 'your_token', // Your custom auth token\n            'Referer': 'www.exemple.com', // For Ionic 2 you might need this\n        });\n    }\n\n    takePhoto() {\n        this._cameraService.takePhoto({ allowEdit: true, imageSize: 300 })\n            .catch((error) =\u003e {\n                console.error('Take photo error', error);\n                return Observable.empty();\n            })\n            .subscribe((dataURI) =\u003e {\n\n                const uploadAvatar = this._uploadService\n                    .upload\u003cstring\u003e('/api/user/logo/', 'avatar_url', dataURI);\n\n                uploadAvatar.uploadProgress$\n                    .subscribe((progress) =\u003e {\n                        console.info('Uploading in progress:', progress);\n                    });\n\n                uploadAvatar.uploadResult$\n                    .catch((error) =\u003e {\n                        console.error('Upload error:', error);\n                        return Observable.empty();\n                    })\n                    .subscribe((response) =\u003e {\n                        console.info('Upload success with api response', response);\n                    });\n            });\n    }\n\n}\n\n```\n\n##  Todos\n - Write Tests\n - Add exemple website\n - Implementing and test on Electron\n - Consider add vanilla Cordova platform (not bing on ionic-native)\n\nLicense\n----\n\nMIT\n\n[//]: # (These are reference links used in the body of this note and get stripped out when the markdown processor does its job. There is no need to format nicely because it shouldn't be seen. Thanks SO - http://stackoverflow.com/questions/4823468/store-comments-in-markdown-syntax)\n\n   [AngularJS]: \u003chttp://angular.io\u003e\n   [Typecript]: \u003chttp://typscriptlang.org\u003e\n   [Ionic2]: \u003chttp://ionicframework.com\u003e\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasgazzoni%2Fng2-platform","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fthomasgazzoni%2Fng2-platform","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fthomasgazzoni%2Fng2-platform/lists"}