diff options
| author | Jules Laplace <jules@okfoc.us> | 2017-02-16 02:16:54 +0100 |
|---|---|---|
| committer | Jules Laplace <jules@okfoc.us> | 2017-02-16 02:16:54 +0100 |
| commit | 27b2ba4ae21289022499111f7b2a54d4423745cc (patch) | |
| tree | f1a7d835dcd8ef008df22f54d748b52c35b31c30 | |
| parent | 282ca1915baf398cfae5500a1eeb70f405343c2e (diff) | |
build
4 files changed, 105 insertions, 89 deletions
diff --git a/StoneIsland/platforms/ios/Stone Island/Stone Island-Info.plist b/StoneIsland/platforms/ios/Stone Island/Stone Island-Info.plist index c395eefd..1d150c34 100644 --- a/StoneIsland/platforms/ios/Stone Island/Stone Island-Info.plist +++ b/StoneIsland/platforms/ios/Stone Island/Stone Island-Info.plist @@ -21,11 +21,11 @@ <key>CFBundlePackageType</key> <string>APPL</string> <key>CFBundleShortVersionString</key> - <string>0.8.1</string> + <string>0.8.3</string> <key>CFBundleSignature</key> <string>????</string> <key>CFBundleVersion</key> - <string>0.8.1</string> + <string>0.8.3</string> <key>LSRequiresIPhoneOS</key> <true/> <key>NSMainNibFile</key> diff --git a/StoneIsland/platforms/ios/Stone Island/config.xml b/StoneIsland/platforms/ios/Stone Island/config.xml index e2b93dd0..ad07ef27 100755 --- a/StoneIsland/platforms/ios/Stone Island/config.xml +++ b/StoneIsland/platforms/ios/Stone Island/config.xml @@ -1,5 +1,5 @@ <?xml version='1.0' encoding='utf-8'?> -<widget id="us.okfoc.stoneisland" version="0.8.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> +<widget id="us.okfoc.stoneisland" version="0.8.3" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0"> <feature name="LocalStorage"> <param name="ios-package" value="CDVLocalStorage" /> </feature> @@ -15,6 +15,41 @@ <param name="ios-package" value="CDVGestureHandler" /> <param name="onload" value="true" /> </feature> + <feature name="ParsePlugin"> + <param name="ios-package" value="CDVParsePlugin" /> + </feature> + <feature name="Console"> + <param name="ios-package" value="CDVLogger" /> + </feature> + <feature name="Device"> + <param name="ios-package" value="CDVDevice" /> + </feature> + <feature name="Notification"> + <param name="ios-package" value="CDVNotification" /> + </feature> + <feature name="Geolocation"> + <param name="ios-package" value="CDVLocation" /> + </feature> + <feature name="InAppBrowser"> + <param name="ios-package" value="CDVInAppBrowser" /> + </feature> + <feature name="NetworkStatus"> + <param name="ios-package" value="CDVConnection" /> + </feature> + <feature name="SplashScreen"> + <param name="ios-package" value="CDVSplashScreen" /> + <param name="onload" value="true" /> + </feature> + <feature name="SocialSharing"> + <param name="ios-package" value="SocialSharing" /> + <param name="onload" value="true" /> + </feature> + <feature name="Keyboard"> + <param name="ios-package" onload="true" value="IonicKeyboard" /> + </feature> + <feature name="PushNotification"> + <param name="ios-package" value="PushPlugin" /> + </feature> <name>Stone Island</name> <description> Stone Island @@ -54,39 +89,4 @@ <preference name="SplashMaintainAspectRatio" value="true" /> <preference name="ShowSplashScreenSpinner" value="false" /> <preference name="AutoHideSplashScreen" value="false" /> - <feature name="ParsePlugin"> - <param name="ios-package" value="CDVParsePlugin" /> - </feature> - <feature name="Console"> - <param name="ios-package" value="CDVLogger" /> - </feature> - <feature name="Device"> - <param name="ios-package" value="CDVDevice" /> - </feature> - <feature name="Notification"> - <param name="ios-package" value="CDVNotification" /> - </feature> - <feature name="Geolocation"> - <param name="ios-package" value="CDVLocation" /> - </feature> - <feature name="InAppBrowser"> - <param name="ios-package" value="CDVInAppBrowser" /> - </feature> - <feature name="NetworkStatus"> - <param name="ios-package" value="CDVConnection" /> - </feature> - <feature name="SplashScreen"> - <param name="ios-package" value="CDVSplashScreen" /> - <param name="onload" value="true" /> - </feature> - <feature name="SocialSharing"> - <param name="ios-package" value="SocialSharing" /> - <param name="onload" value="true" /> - </feature> - <feature name="Keyboard"> - <param name="ios-package" onload="true" value="IonicKeyboard" /> - </feature> - <feature name="PushNotification"> - <param name="ios-package" value="PushPlugin" /> - </feature> </widget> diff --git a/StoneIsland/platforms/ios/cordova/build-extras.xcconfig b/StoneIsland/platforms/ios/cordova/build-extras.xcconfig index 7e631112..e69de29b 100755 --- a/StoneIsland/platforms/ios/cordova/build-extras.xcconfig +++ b/StoneIsland/platforms/ios/cordova/build-extras.xcconfig @@ -1,22 +0,0 @@ -// -// Licensed to the Apache Software Foundation (ASF) under one -// or more contributor license agreements. See the NOTICE file -// distributed with this work for additional information -// regarding copyright ownership. The ASF licenses this file -// to you under the Apache License, Version 2.0 (the -// "License"); you may not use this file except in compliance -// with the License. You may obtain a copy of the License at -// -// http://www.apache.org/licenses/LICENSE-2.0 -// -// Unless required by applicable law or agreed to in writing, -// software distributed under the License is distributed on an -// "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -// KIND, either express or implied. See the License for the -// specific language governing permissions and limitations -// under the License. -// - -// -// Auto-generated config file to override configuration files (build-release/build-debug). -// diff --git a/StoneIsland/platforms/ios/www/js/lib/etc/push.js b/StoneIsland/platforms/ios/www/js/lib/etc/push.js index 634ffe6d..bf7185e6 100755 --- a/StoneIsland/platforms/ios/www/js/lib/etc/push.js +++ b/StoneIsland/platforms/ios/www/js/lib/etc/push.js @@ -2,49 +2,86 @@ var push = (function(){ var appId = "GS82ZxpN8Mecpc53rsyu6aLLGK0W4CKi42J25DLB" var clientKey = "hQRtQfsgimYnX5PMivtcdXCG9eZhESeyTr0Rd8Sv" var push = { settings: {} } - var parsePlugin + var pushPlugin push.init = function(){ - parsePlugin = window.parsePlugin || { initialize: function(){} } - parsePlugin.initialize(appId, clientKey, push.did_initialize, push.error) - } - push.did_initialize = function() { - parsePlugin.registerCallback('onNotification', function(){ - window.onNotification = push.got_push_notification - }, push.error) + + pushPlugin = PushNotification.init({ + ios: { + alert: true, + badge: true, + sound: false, + clearBadge: true, + }, + }) + + push.settings.requested = localStorage.getItem("yoox.push_requested") == "true" + push.settings.hub = localStorage.getItem("yoox.push_hub") == "true" + push.settings.store = localStorage.getItem("yoox.push_store") == "true" + pushPlugin.hasPermission(push.did_initialize) + pushPlugin.on('registration', push.got_registration) + pushPlugin.on('notification', push.got_push_notification) + } + push.did_initialize = function(data) { + if (! data.isEnabled) { + return + } push.settings.requested = localStorage.getItem("yoox.push_requested") == "true" push.settings.hub = localStorage.getItem("yoox.push_hub") == "true" push.settings.store = localStorage.getItem("yoox.push_store") == "true" + } + push.got_registration = function(data){ + var registrationId = data.registrationId + var oldRegistrationId = localStorage.getItem("yoox.registrationId") + console.log(registrationId, oldRegistrationId) - if ( ! push.settings.requested ) { - localStorage.setItem("yoox.push_requested", "true") + if (registrationId !== oldRegistrationId || ! push.settings.requested) { + localStorage.setItem("yoox.registrationId", registrationId) push.subscribe("hub", function(){ push.subscribe("store") }) } } push.subscribe = function(channel, cb){ - parsePlugin.subscribe(channel, function(){ - push.settings[channel] = true - localStorage.setItem("yoox.push_" + channel, "true") - console.log("subscribed to", channel) - cb && cb() - }, push.error) + push.settings[channel] = true + localStorage.setItem("yoox.push_" + channel, "true") + var data = { + registrationId: localStorage.getItem("yoox.registrationId"), + channel: channel, + platform: device.platform, + } + $.ajax({ + method: "POST", + url: "https://stone.sup.land/_services/push/add", + data: data, + contentType: 'application/x-www-form-urlencoded; charset=UTF-8', + success: function(){ + console.log("subscribed to", channel) + cb && cb() + }, + error: push.error, + }) } push.unsubscribe = function(channel, cb){ - parsePlugin.unsubscribe(channel, function(){ - push.settings[channel] = false - localStorage.setItem("yoox.push_" + channel, "false") - console.log("unsubscribed from", channel) - cb && cb() - }, push.error) + push.settings[channel] = false + localStorage.setItem("yoox.push_" + channel, "false") + var data = { + registrationId: localStorage.getItem("yoox.registrationId"), + channel: channel, + platform: device.platform, + } + $.ajax({ + method: "POST", + url: "https://stone.sup.land/_services/push/remove", + data: data, + contentType: 'application/x-www-form-urlencoded; charset=UTF-8', + success: function(){ + console.log("unsubscribed from", channel) + cb && cb() + }, + error: push.error, + }) } - // parsePlugin.getInstallationId(function(id) { - // var install_data = { - // installation_id: id, - // channels: ['SampleChannel'] - // } - // }, push.error) push.got_push_notification = function(push_obj) { // alert('We received this push notification: ' + JSON.stringify(push_obj)); app.blog.refresh() @@ -63,8 +100,9 @@ var push = (function(){ app.intro.$alert.show().html("[ HUB UPDATED ]") } - if (push_obj.receivedInForeground === false) { + if (push_obj.additionalData.foreground === false) { // TODO: route the user to the uri in push_obj + pushPlugin.finish(function(){}, function(){}) } else { app.route("intro") |
