This repository has been archived by the owner on Sep 4, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
🕸️ Issue #2109: Receive push notifications when using cordova-browser…
… > 5.0.0
- Loading branch information
Showing
2 changed files
with
50 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
module.exports = function(context) { | ||
console.log('Updating manifest.json with push properties…'); | ||
var path = require('path'); | ||
var fs = require('fs'); | ||
|
||
var platformProjPath = path.join( | ||
context.opts.projectRoot, | ||
'platforms/browser' | ||
); | ||
|
||
if (!fs.existsSync(platformProjPath)) { | ||
platformProjPath = context.opts.projectRoot; | ||
} | ||
|
||
var platformManifestJson = path.join(platformProjPath, 'www/manifest.json'); | ||
|
||
if (!fs.existsSync(platformManifestJson)) { | ||
return; | ||
} | ||
|
||
fs.readFile(platformManifestJson, 'utf8', function(err, platformJson) { | ||
if (err) throw err; // we'll not consider error handling for now | ||
var platformManifest = JSON.parse(platformJson); | ||
|
||
var pluginManifestPath = path.join( | ||
context.opts.projectRoot, | ||
'plugins/phonegap-plugin-push/src/browser/manifest.json' | ||
); | ||
|
||
fs.readFile(pluginManifestPath, 'utf8', function(err, pluginJson) { | ||
if (err) throw err; // we'll not consider error handling for now | ||
var pluginManifest = JSON.parse(pluginJson); | ||
|
||
platformManifest['gcm_sender_id'] = pluginManifest['gcm_sender_id']; | ||
|
||
fs.writeFile( | ||
platformManifestJson, | ||
JSON.stringify(platformManifest), | ||
function(err) { | ||
if (err) { | ||
return console.log(err); | ||
} | ||
|
||
console.log('Manifest updated with push sender ID'); | ||
} | ||
); | ||
}); | ||
}); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters