Skip to content

Commit

Permalink
some revised features.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfeng99 committed Jul 29, 2019
1 parent 6a56898 commit 1bf5aa3
Show file tree
Hide file tree
Showing 10 changed files with 337 additions and 188 deletions.
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
package com.xflying.ane.AirPushNotification
{
import flash.events.EventDispatcher;
import flash.events.StageOrientationEvent;
import flash.events.StatusEvent;
import flash.events.InvokeEvent;
import flash.external.ExtensionContext;
import flash.system.Capabilities;
import flash.filesystem.File;
import flash.desktop.NativeApplication;

import com.xflying.ane.AirPushNotification.PushNotificationEvent;

public class PushNotification extends EventDispatcher
import mx.core.FlexGlobals;

public class PushNotification extends EventDispatcher
{
private const LOG:String = "[PushNotification-as3]";
private const iOS:Boolean = Capabilities.version.indexOf('IOS') >= 0 ? true : false;
Expand All @@ -27,9 +27,20 @@ package com.xflying.ane.AirPushNotification
private static var extCtx:ExtensionContext = null;

private static var _instance:PushNotification;

private var _orientation:String = "rotatedRight";

private var _isInitialized:Boolean=false;


public function set orientation(ori:String):void{
_orientation = ori;
if(iOS)
extCtx.call("setMessageOrientation", ori);
}

public function get orientation():String {
return _orientation;
}

public function PushNotification()
{
Expand All @@ -43,6 +54,7 @@ package com.xflying.ane.AirPushNotification
if (extCtx != null)
{
extCtx.addEventListener(StatusEvent.STATUS, onStatus);
FlexGlobals.topLevelApplication.stage.addEventListener(StageOrientationEvent.ORIENTATION_CHANGE, stageOrientationChangingHandler);
_isInitialized = true;
} else
{
Expand Down Expand Up @@ -124,7 +136,7 @@ package com.xflying.ane.AirPushNotification
}
}

public function showNotificationsForground(title:String, body:String, goURL:String):void{
public function showNotificationsForground(title:String, body:String, goURL:String = null):void{
if (iOS && this.notificationsEnabled)
{
extCtx.call("showNotificationsForground", title, body, goURL);
Expand Down Expand Up @@ -203,6 +215,11 @@ package com.xflying.ane.AirPushNotification
extCtx.call("fetchStarterNotification");
}

private function stageOrientationChangingHandler(e:StageOrientationEvent):void{
orientation = e.afterOrientation;
trace(LOG, "set push message orientation to",orientation);
}

// public function storeTrackingNotifUrl(url:String):void
// {
// if (this.isInitialized)
Expand Down Expand Up @@ -355,6 +372,6 @@ package com.xflying.ane.AirPushNotification
}
}
}

}
}
3 changes: 2 additions & 1 deletion sample_clients/ANE-Push-Notification/android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,11 @@ buildscript {

repositories {
jcenter()
google()
}

dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
classpath 'com.android.tools.build:gradle:3.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.1'
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Thu Aug 17 17:44:16 CST 2017
#Tue Jul 02 07:55:43 CST 2019
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-4.10.1-all.zip
168 changes: 84 additions & 84 deletions sample_clients/ANE-Push-Notification/android/gradlew.bat
Original file line number Diff line number Diff line change
@@ -1,84 +1,84 @@
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
@if "%DEBUG%" == "" @echo off
@rem ##########################################################################
@rem
@rem Gradle startup script for Windows
@rem
@rem ##########################################################################

@rem Set local scope for the variables with windows NT shell
if "%OS%"=="Windows_NT" setlocal

set DIRNAME=%~dp0
if "%DIRNAME%" == "" set DIRNAME=.
set APP_BASE_NAME=%~n0
set APP_HOME=%DIRNAME%

@rem Add default JVM options here. You can also use JAVA_OPTS and GRADLE_OPTS to pass JVM options to this script.
set DEFAULT_JVM_OPTS=

@rem Find java.exe
if defined JAVA_HOME goto findJavaFromJavaHome

set JAVA_EXE=java.exe
%JAVA_EXE% -version >NUL 2>&1
if "%ERRORLEVEL%" == "0" goto init

echo.
echo ERROR: JAVA_HOME is not set and no 'java' command could be found in your PATH.
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:findJavaFromJavaHome
set JAVA_HOME=%JAVA_HOME:"=%
set JAVA_EXE=%JAVA_HOME%/bin/java.exe

if exist "%JAVA_EXE%" goto init

echo.
echo ERROR: JAVA_HOME is set to an invalid directory: %JAVA_HOME%
echo.
echo Please set the JAVA_HOME variable in your environment to match the
echo location of your Java installation.

goto fail

:init
@rem Get command-line arguments, handling Windows variants

if not "%OS%" == "Windows_NT" goto win9xME_args

:win9xME_args
@rem Slurp the command line arguments.
set CMD_LINE_ARGS=
set _SKIP=2

:win9xME_args_slurp
if "x%~1" == "x" goto execute

set CMD_LINE_ARGS=%*

:execute
@rem Setup the command line

set CLASSPATH=%APP_HOME%\gradle\wrapper\gradle-wrapper.jar

@rem Execute Gradle
"%JAVA_EXE%" %DEFAULT_JVM_OPTS% %JAVA_OPTS% %GRADLE_OPTS% "-Dorg.gradle.appname=%APP_BASE_NAME%" -classpath "%CLASSPATH%" org.gradle.wrapper.GradleWrapperMain %CMD_LINE_ARGS%

:end
@rem End local scope for the variables with windows NT shell
if "%ERRORLEVEL%"=="0" goto mainEnd

:fail
rem Set variable GRADLE_EXIT_CONSOLE if you need the _script_ return code instead of
rem the _cmd.exe /c_ return code!
if not "" == "%GRADLE_EXIT_CONSOLE%" exit 1
exit /b 1

:mainEnd
if "%OS%"=="Windows_NT" endlocal

:omega
Loading

0 comments on commit 1bf5aa3

Please sign in to comment.